Fix #4115: Upgrade to webpack 4.x.
https://github.com/rails/webpacker/blob/master/docs/v4-upgrade.md
This commit is contained in:
18
.babelrc
18
.babelrc
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"presets": [
|
|
||||||
["env", {
|
|
||||||
"modules": false,
|
|
||||||
"targets": {
|
|
||||||
"browsers": "> 1%",
|
|
||||||
"uglify": true
|
|
||||||
},
|
|
||||||
"useBuiltIns": true
|
|
||||||
}]
|
|
||||||
],
|
|
||||||
|
|
||||||
"plugins": [
|
|
||||||
"syntax-dynamic-import",
|
|
||||||
"transform-object-rest-spread",
|
|
||||||
["transform-class-properties", { "spec": true }]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
plugins:
|
|
||||||
postcss-import: {}
|
|
||||||
postcss-cssnext: {}
|
|
||||||
72
babel.config.js
Normal file
72
babel.config.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
module.exports = function(api) {
|
||||||
|
var validEnv = ['development', 'test', 'production']
|
||||||
|
var currentEnv = api.env()
|
||||||
|
var isDevelopmentEnv = api.env('development')
|
||||||
|
var isProductionEnv = api.env('production')
|
||||||
|
var isTestEnv = api.env('test')
|
||||||
|
|
||||||
|
if (!validEnv.includes(currentEnv)) {
|
||||||
|
throw new Error(
|
||||||
|
'Please specify a valid `NODE_ENV` or ' +
|
||||||
|
'`BABEL_ENV` environment variables. Valid values are "development", ' +
|
||||||
|
'"test", and "production". Instead, received: ' +
|
||||||
|
JSON.stringify(currentEnv) +
|
||||||
|
'.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
presets: [
|
||||||
|
isTestEnv && [
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
targets: {
|
||||||
|
node: 'current'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
(isProductionEnv || isDevelopmentEnv) && [
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
forceAllTransforms: true,
|
||||||
|
useBuiltIns: 'entry',
|
||||||
|
corejs: 3,
|
||||||
|
modules: false,
|
||||||
|
exclude: ['transform-typeof-symbol']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
].filter(Boolean),
|
||||||
|
plugins: [
|
||||||
|
'babel-plugin-macros',
|
||||||
|
'@babel/plugin-syntax-dynamic-import',
|
||||||
|
isTestEnv && 'babel-plugin-dynamic-import-node',
|
||||||
|
'@babel/plugin-transform-destructuring',
|
||||||
|
[
|
||||||
|
'@babel/plugin-proposal-class-properties',
|
||||||
|
{
|
||||||
|
loose: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@babel/plugin-proposal-object-rest-spread',
|
||||||
|
{
|
||||||
|
useBuiltIns: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@babel/plugin-transform-runtime',
|
||||||
|
{
|
||||||
|
helpers: false,
|
||||||
|
regenerator: true,
|
||||||
|
corejs: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@babel/plugin-transform-regenerator',
|
||||||
|
{
|
||||||
|
async: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
].filter(Boolean)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,11 @@
|
|||||||
default: &default
|
default: &default
|
||||||
source_path: app/javascript
|
source_path: app/javascript
|
||||||
source_entry_path: packs
|
source_entry_path: packs
|
||||||
|
public_root_path: public
|
||||||
public_output_path: packs
|
public_output_path: packs
|
||||||
cache_path: tmp/cache/webpacker
|
cache_path: tmp/cache/webpacker
|
||||||
|
check_yarn_integrity: false
|
||||||
|
webpack_compile_output: false
|
||||||
|
|
||||||
# Additional paths webpack should lookup modules
|
# Additional paths webpack should lookup modules
|
||||||
# ['app/assets', 'engine/foo/app/assets']
|
# ['app/assets', 'engine/foo/app/assets']
|
||||||
@@ -13,8 +16,26 @@ default: &default
|
|||||||
# Reload manifest.json on all requests so we reload latest compiled packs
|
# Reload manifest.json on all requests so we reload latest compiled packs
|
||||||
cache_manifest: false
|
cache_manifest: false
|
||||||
|
|
||||||
|
# Extract and emit a css file
|
||||||
|
extract_css: false
|
||||||
|
|
||||||
|
static_assets_extensions:
|
||||||
|
- .jpg
|
||||||
|
- .jpeg
|
||||||
|
- .png
|
||||||
|
- .gif
|
||||||
|
- .tiff
|
||||||
|
- .ico
|
||||||
|
- .svg
|
||||||
|
- .eot
|
||||||
|
- .otf
|
||||||
|
- .ttf
|
||||||
|
- .woff
|
||||||
|
- .woff2
|
||||||
|
|
||||||
extensions:
|
extensions:
|
||||||
- .erb
|
- .erb
|
||||||
|
- .mjs
|
||||||
- .js
|
- .js
|
||||||
- .sass
|
- .sass
|
||||||
- .scss
|
- .scss
|
||||||
@@ -32,6 +53,9 @@ development:
|
|||||||
<<: *default
|
<<: *default
|
||||||
compile: true
|
compile: true
|
||||||
|
|
||||||
|
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
|
||||||
|
check_yarn_integrity: true
|
||||||
|
|
||||||
# Reference: https://webpack.js.org/configuration/dev-server/
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
||||||
dev_server:
|
dev_server:
|
||||||
https: false
|
https: false
|
||||||
@@ -49,7 +73,7 @@ development:
|
|||||||
headers:
|
headers:
|
||||||
'Access-Control-Allow-Origin': '*'
|
'Access-Control-Allow-Origin': '*'
|
||||||
watch_options:
|
watch_options:
|
||||||
ignored: /node_modules/
|
ignored: '**/node_modules/**'
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@@ -65,5 +89,8 @@ production:
|
|||||||
# Production depends on precompilation of packs prior to booting for performance.
|
# Production depends on precompilation of packs prior to booting for performance.
|
||||||
compile: false
|
compile: false
|
||||||
|
|
||||||
|
# Extract and emit a css file
|
||||||
|
extract_css: true
|
||||||
|
|
||||||
# Cache manifest.json for performance
|
# Cache manifest.json for performance
|
||||||
cache_manifest: true
|
cache_manifest: true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rails/webpacker": "^3.5.3",
|
"@rails/webpacker": "^4.0.0",
|
||||||
"debug-loader": "^0.0.1",
|
"debug-loader": "^0.0.1",
|
||||||
"expose-loader": "^0.7.5",
|
"expose-loader": "^0.7.5",
|
||||||
"hammerjs": "^2.0.8",
|
"hammerjs": "^2.0.8",
|
||||||
|
|||||||
12
postcss.config.js
Normal file
12
postcss.config.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
require('postcss-import'),
|
||||||
|
require('postcss-flexbugs-fixes'),
|
||||||
|
require('postcss-preset-env')({
|
||||||
|
autoprefixer: {
|
||||||
|
flexbox: 'no-2009'
|
||||||
|
},
|
||||||
|
stage: 3
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user