Skip to content

Commit

Permalink
changed webpack confs
Browse files Browse the repository at this point in the history
  • Loading branch information
olegphenomenon committed Apr 21, 2023
1 parent c77ae70 commit d0447e6
Show file tree
Hide file tree
Showing 11 changed files with 3,264 additions and 1,987 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04]
os: [ubuntu-20.04]
ruby: [ '3.0.3' ]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
Expand Down Expand Up @@ -87,9 +87,9 @@ jobs:
upload_coverage:
strategy:
matrix:
os: [ ubuntu-18.04 ]
os: [ubuntu-20.04]
ruby: [ '3.0.3' ]
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ gem 'rexml', '~> 3.2', '>= 3.2.4'
gem 'faraday'
gem 'faraday_middleware'
gem 'figaro'
gem 'terser'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
30 changes: 17 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ GEM
xpath (~> 3.2)
childprocess (4.1.0)
coderay (1.1.3)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
crass (1.0.6)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
Expand All @@ -100,7 +100,8 @@ GEM
warden (~> 1.2.3)
diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.11.0)
erubi (1.12.0)
execjs (2.8.1)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
Expand Down Expand Up @@ -159,7 +160,7 @@ GEM
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.19.1)
loofah (2.20.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -168,12 +169,12 @@ GEM
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.17.0)
minitest (5.18.0)
msgpack (1.5.2)
multipart-post (2.2.0)
nested_form (0.3.2)
nio4r (2.5.8)
nokogiri (1.13.10-x86_64-linux)
nokogiri (1.14.3-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
pg (1.3.5)
Expand All @@ -183,13 +184,13 @@ GEM
public_suffix (4.0.7)
puma (6.0.0)
nio4r (~> 2.0)
racc (1.6.1)
rack (2.2.6.2)
racc (1.6.2)
rack (2.2.6.4)
rack-mini-profiler (3.0.0)
rack (>= 1.2.0)
rack-proxy (0.7.2)
rack-proxy (0.7.6)
rack
rack-test (2.0.2)
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.6)
actioncable (= 6.1.6)
Expand All @@ -213,7 +214,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.4)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
rails_admin (3.0.0)
activemodel-serializers-xml (>= 1.0)
Expand Down Expand Up @@ -286,6 +287,8 @@ GEM
sprockets (>= 3.0.0)
tailwindcss-rails (2.0.8-x86_64-linux)
railties (>= 6.0.0)
terser (1.1.14)
execjs (>= 0.3.0, < 3)
thor (1.2.1)
tilt (2.0.10)
turbo-rails (1.1.1)
Expand All @@ -295,7 +298,7 @@ GEM
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (2.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
warden (1.2.9)
rack (>= 2.0.9)
Expand All @@ -308,7 +311,7 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webpacker (5.4.3)
webpacker (5.4.4)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
Expand All @@ -319,7 +322,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.6)
zeitwerk (2.6.7)

PLATFORMS
x86_64-linux
Expand Down Expand Up @@ -352,6 +355,7 @@ DEPENDENCIES
simplecov (= 0.17.1)
spring
tailwindcss-rails (~> 2.0.0)
terser
turbolinks (~> 5)
tzinfo-data
web-console (>= 4.1.0)
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class Application < Rails::Application
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.middleware.use Rack::Deflater

config.assets.js_compressor = Terser::Compressor.new
config.assets.css_compressor = :sass
end

Rails.application.config.assets.configure do |env|
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress CSS using a preprocessor.
config.assets.css_compressor = :purger
# config.assets.css_compressor = :purger

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
Expand Down
9 changes: 4 additions & 5 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
require 'syslog/logger'
config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new(ENV['app_name'] || 'accreditation'))

# Enable stdout logger
config.logger = Logger.new(STDOUT)

# Set log level
config.log_level = :ERROR
# Enable stdout logger
config.logger = Logger.new(STDOUT)

# Set log level
config.log_level = :ERROR
end
61 changes: 34 additions & 27 deletions config/webpack/base.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
// const { webpackConfig } = require('@rails/webpacker')
const { environment } = require('@rails/webpacker')

// module.exports = webpackConfig

const { webpackConfig, merge } = require('@rails/webpacker')
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const customConfig = {
resolve: {
fallback: {
dgram: false,
fs: false,
net: false,
tls: false,
child_process: false
}
}
};

const plugins = [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery'
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
]
environment.config.delete('node.dgram')
environment.config.delete('node.fs')
environment.config.delete('node.net')
environment.config.delete('node.tls')
environment.config.delete('node.child_process')

module.exports = merge(
webpackConfig,
{
module: {
rules: []
environment.loaders.append('sass', {
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: ['app/assets/stylesheets'],
},
},
plugins: plugins,
}
)
},
],
});

environment.config.merge(customConfig);

const scssConfigIndex = webpackConfig.module.rules.findIndex((config) => ".scss".match(config.test))
webpackConfig.module.rules.splice(scssConfigIndex, 1)
module.exports = environment
2 changes: 2 additions & 0 deletions config/webpack/development.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { environment } = require('@rails/webpacker')

process.env.NODE_ENV = process.env.NODE_ENV || 'development'

// const environment = require('./environment')
Expand Down
53 changes: 47 additions & 6 deletions config/webpack/environment.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
// const { environment } = require('@rails/webpacker')

// const webpack = require('webpack');
// environment.plugins.append('Provide', new webpack.ProvidePlugin({
// $: 'jquery',
// jQuery: 'jquery',
// Popper: ['popper.js', 'default']
// }))

// module.exports = environment

const { environment } = require('@rails/webpacker')

const webpack = require('webpack');
environment.plugins.append('Provide', new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
Popper: ['popper.js', 'default']
}))
const customConfig = {
resolve: {
fallback: {
dgram: false,
fs: false,
net: false,
tls: false,
child_process: false
}
}
};

environment.config.delete('node.dgram')
environment.config.delete('node.fs')
environment.config.delete('node.net')
environment.config.delete('node.tls')
environment.config.delete('node.child_process')

environment.loaders.append('sass', {
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: ['app/assets/stylesheets'],
},
},
},
],
});

environment.config.merge(customConfig);

module.exports = environment

20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@
"@rails/ujs": "^7.0.0",
"@rails/webpacker": "5.4.4",
"jquery": "^3.6.0",
"node-polyfill-webpack-plugin": "^2.0.1",
"popper.js": "^1.16.1",
"toastr": "^2.1.4",
"turbolinks": "^5.2.0",
"webpack": "^5.0.0",
"webpack-cli": "^5.0.0"
"webpack-cli": "^5.0.0",
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"babel-loader": "^9.1.2",
"sass-loader": "^13.2.2",
"style-loader": "^3.3.2",
"css-loader": "^6.7.3"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^4.11.1"
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"babel-loader": "^9.1.2",
"css-loader": "^6.7.3",
"mini-css-extract-plugin": "^2.7.5",
"node-sass": "^8.0.0",
"sass-loader": "^13.2.2",
"style-loader": "^3.3.2",
"webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.8.0"
}
}
Loading

0 comments on commit d0447e6

Please sign in to comment.