Migrate assets to use Webpacker
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
Rails.application.configure do
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = true
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Rails.application.configure do
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = false
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
|
||||
5
config/webpack/development.js
Normal file
5
config/webpack/development.js
Normal file
@@ -0,0 +1,5 @@
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
||||
|
||||
const environment = require('./environment')
|
||||
|
||||
module.exports = environment.toWebpackConfig()
|
||||
23
config/webpack/environment.js
Normal file
23
config/webpack/environment.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { environment } = require('@rails/webpacker')
|
||||
const erb = require('./loaders/erb')
|
||||
const webpack = require('webpack');
|
||||
|
||||
environment.loaders.append('scss.erb', {
|
||||
test: /\.scss\.erb$/,
|
||||
enforce: 'pre',
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
'style-loader',
|
||||
'postcss-loader',
|
||||
'sass-loader',
|
||||
'rails-erb-loader'
|
||||
]
|
||||
});
|
||||
|
||||
environment.loaders.append('erb', erb);
|
||||
|
||||
environment.config.externals = {
|
||||
jquery: "jQuery"
|
||||
}
|
||||
|
||||
module.exports = environment
|
||||
11
config/webpack/loaders/erb.js
Normal file
11
config/webpack/loaders/erb.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
test: /\.erb$/,
|
||||
enforce: 'pre',
|
||||
exclude: /node_modules/,
|
||||
use: [{
|
||||
loader: 'rails-erb-loader',
|
||||
options: {
|
||||
runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner'
|
||||
}
|
||||
}]
|
||||
}
|
||||
5
config/webpack/production.js
Normal file
5
config/webpack/production.js
Normal file
@@ -0,0 +1,5 @@
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
||||
|
||||
const environment = require('./environment')
|
||||
|
||||
module.exports = environment.toWebpackConfig()
|
||||
5
config/webpack/test.js
Normal file
5
config/webpack/test.js
Normal file
@@ -0,0 +1,5 @@
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
||||
|
||||
const environment = require('./environment')
|
||||
|
||||
module.exports = environment.toWebpackConfig()
|
||||
69
config/webpacker.yml
Normal file
69
config/webpacker.yml
Normal file
@@ -0,0 +1,69 @@
|
||||
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||
|
||||
default: &default
|
||||
source_path: app/javascript
|
||||
source_entry_path: packs
|
||||
public_output_path: packs
|
||||
cache_path: tmp/cache/webpacker
|
||||
|
||||
# Additional paths webpack should lookup modules
|
||||
# ['app/assets', 'engine/foo/app/assets']
|
||||
resolved_paths: []
|
||||
|
||||
# Reload manifest.json on all requests so we reload latest compiled packs
|
||||
cache_manifest: false
|
||||
|
||||
extensions:
|
||||
- .erb
|
||||
- .js
|
||||
- .sass
|
||||
- .scss
|
||||
- .css
|
||||
- .module.sass
|
||||
- .module.scss
|
||||
- .module.css
|
||||
- .png
|
||||
- .svg
|
||||
- .gif
|
||||
- .jpeg
|
||||
- .jpg
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
compile: true
|
||||
|
||||
# Reference: https://webpack.js.org/configuration/dev-server/
|
||||
dev_server:
|
||||
https: false
|
||||
host: localhost
|
||||
port: 3035
|
||||
public: localhost:3035
|
||||
hmr: false
|
||||
# Inline should be set to true if using HMR
|
||||
inline: true
|
||||
overlay: true
|
||||
compress: true
|
||||
disable_host_check: true
|
||||
use_local_ip: false
|
||||
quiet: false
|
||||
headers:
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
watch_options:
|
||||
ignored: /node_modules/
|
||||
|
||||
|
||||
test:
|
||||
<<: *default
|
||||
compile: true
|
||||
|
||||
# Compile test packs to a separate directory
|
||||
public_output_path: packs-test
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
|
||||
# Production depends on precompilation of packs prior to booting for performance.
|
||||
compile: false
|
||||
|
||||
# Cache manifest.json for performance
|
||||
cache_manifest: true
|
||||
Reference in New Issue
Block a user