Skip to content

Commit 0ebb126

Browse files
committedMar 21, 2019
Upgrade to using webpacker 4.0 following below document:
https://github.com/rails/webpacker/blob/master/docs/v4-upgrade.md
1 parent 9a4e602 commit 0ebb126

10 files changed

+2690
-2396
lines changed
 

‎.babelrc

-18
This file was deleted.

‎.browserslistrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
defaults

‎.postcssrc.yml

-3
This file was deleted.

‎Gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ gem 'sassc-rails'
2020
# Use Uglifier as compressor for JavaScript assets
2121
gem 'uglifier', '>= 1.3.0'
2222
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
23-
gem 'webpacker', '~> 3.6.0'
23+
gem 'webpacker', '~> 4.0'
24+
2425
# See https://github.com/rails/execjs#readme for more supported runtimes
2526
# gem 'mini_racer', platforms: :ruby
2627

‎Gemfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ GEM
236236
activemodel (>= 5.0)
237237
bindex (>= 0.4.0)
238238
railties (>= 5.0)
239-
webpacker (3.6.0)
239+
webpacker (4.0.2)
240240
activesupport (>= 4.2)
241241
rack-proxy (>= 0.6.1)
242242
railties (>= 4.2)
@@ -280,7 +280,7 @@ DEPENDENCIES
280280
tzinfo-data
281281
uglifier (>= 1.3.0)
282282
web-console (>= 3.3.0)
283-
webpacker (~> 3.6.0)
283+
webpacker (~> 4.0)
284284

285285
RUBY VERSION
286286
ruby 2.6.1p33

‎babel.config.js

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
module.exports = function(api) {
2+
var validEnv = ['development', 'test', 'production']
3+
var currentEnv = api.env()
4+
var isDevelopmentEnv = api.env('development')
5+
var isProductionEnv = api.env('production')
6+
var isTestEnv = api.env('test')
7+
8+
if (!validEnv.includes(currentEnv)) {
9+
throw new Error(
10+
'Please specify a valid `NODE_ENV` or ' +
11+
'`BABEL_ENV` environment variables. Valid values are "development", ' +
12+
'"test", and "production". Instead, received: ' +
13+
JSON.stringify(currentEnv) +
14+
'.'
15+
)
16+
}
17+
18+
return {
19+
presets: [
20+
isTestEnv && [
21+
require('@babel/preset-env').default,
22+
{
23+
targets: {
24+
node: 'current'
25+
}
26+
}
27+
],
28+
(isProductionEnv || isDevelopmentEnv) && [
29+
require('@babel/preset-env').default,
30+
{
31+
forceAllTransforms: true,
32+
useBuiltIns: 'entry',
33+
modules: false,
34+
exclude: ['transform-typeof-symbol']
35+
}
36+
]
37+
].filter(Boolean),
38+
plugins: [
39+
require('babel-plugin-macros'),
40+
require('@babel/plugin-syntax-dynamic-import').default,
41+
isTestEnv && require('babel-plugin-dynamic-import-node'),
42+
require('@babel/plugin-transform-destructuring').default,
43+
[
44+
require('@babel/plugin-proposal-class-properties').default,
45+
{
46+
loose: true
47+
}
48+
],
49+
[
50+
require('@babel/plugin-proposal-object-rest-spread').default,
51+
{
52+
useBuiltIns: true
53+
}
54+
],
55+
[
56+
require('@babel/plugin-transform-runtime').default,
57+
{
58+
helpers: false,
59+
regenerator: true
60+
}
61+
],
62+
[
63+
require('@babel/plugin-transform-regenerator').default,
64+
{
65+
async: false
66+
}
67+
]
68+
].filter(Boolean)
69+
}
70+
}

‎config/webpacker.yml

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Note: You must restart bin/webpack-dev-server for changes to take effect
2-
2+
---
33
default: &default
44
source_path: app/javascript
55
source_entry_path: packs
6+
public_root_path: public
67
public_output_path: packs
78
cache_path: tmp/cache/webpacker
9+
check_yarn_integrity: false
10+
webpack_compile_output: false
811

912
# Additional paths webpack should lookup modules
1013
# ['app/assets', 'engine/foo/app/assets']
@@ -13,7 +16,25 @@ default: &default
1316
# Reload manifest.json on all requests so we reload latest compiled packs
1417
cache_manifest: false
1518

19+
# Extract and emit a css file
20+
extract_css: false
21+
22+
static_assets_extensions:
23+
- .jpg
24+
- .jpeg
25+
- .png
26+
- .gif
27+
- .tiff
28+
- .ico
29+
- .svg
30+
- .eot
31+
- .otf
32+
- .ttf
33+
- .woff
34+
- .woff2
35+
1636
extensions:
37+
- .mjs
1738
- .js
1839
- .sass
1940
- .scss
@@ -31,6 +52,9 @@ development:
3152
<<: *default
3253
compile: true
3354

55+
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
56+
check_yarn_integrity: true
57+
3458
# Reference: https://webpack.js.org/configuration/dev-server/
3559
dev_server:
3660
https: false
@@ -48,7 +72,7 @@ development:
4872
headers:
4973
'Access-Control-Allow-Origin': '*'
5074
watch_options:
51-
ignored: /node_modules/
75+
ignored: '**/node_modules/**'
5276

5377

5478
test:
@@ -64,5 +88,8 @@ production:
6488
# Production depends on precompilation of packs prior to booting for performance.
6589
compile: false
6690

91+
# Extract and emit a css file
92+
extract_css: true
93+
6794
# Cache manifest.json for performance
6895
cache_manifest: true

‎package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"name": "oauth2id",
33
"private": true,
44
"dependencies": {
5-
"@rails/webpacker": "3.6.0",
5+
"@rails/webpacker": "^4.0.1",
66
"datatables": "^1.10.18",
77
"stimulus": "^1.1.1",
88
"vali-admin": "^2.4.1"
99
},
1010
"devDependencies": {
11-
"webpack-dev-server": "2.11.2"
11+
"webpack": "^4.28.4",
12+
"webpack-dev-server": "^3.2.1"
1213
}
1314
}

‎postcss.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
plugins: [
3+
require('postcss-import'),
4+
require('postcss-flexbugs-fixes'),
5+
require('postcss-preset-env')({
6+
autoprefixer: {
7+
flexbox: 'no-2009'
8+
},
9+
stage: 3
10+
})
11+
]
12+
}

‎yarn.lock

+2,571-2,368
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.