Skip to content

Commit d9d2466

Browse files
committedJun 3, 2018
feat: upgrade to webpack@3
1 parent 1a8726a commit d9d2466

5 files changed

+178
-109
lines changed
 

‎package.json

+17-18
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"author": "Prashant Abhishek <prashant.abhishek7g@gmail.com>, Mayank Chandola <imayankchd@gmail.com>, Sandeep Panda <sandeep@hashnode.com>, Syed Fazle Rahman <fazle@hashnode.com>, Alkshendra Maurya <alkshendra@hashnode.com>",
3232
"license": "MIT",
3333
"dependencies": {
34-
"babel-core": "^6.9.1",
34+
"babel-core": "^6.26.0",
3535
"body-parser": "^1.15.1",
3636
"compression": "^1.6.2",
3737
"cross-env": "^1.0.8",
@@ -55,20 +55,20 @@
5555
"devDependencies": {
5656
"ava": "^0.15.2",
5757
"babel-eslint": "^6.0.4",
58-
"babel-loader": "^6.2.4",
59-
"babel-plugin-webpack-loaders": "^0.7.0",
60-
"babel-polyfill": "^6.9.1",
58+
"babel-loader": "^7.1.2",
59+
"babel-plugin-webpack-loaders": "^0.9.0",
60+
"babel-polyfill": "^6.26.0",
6161
"babel-preset-es2015": "^6.9.0",
6262
"babel-preset-es2015-native-modules": "^6.6.0",
6363
"babel-preset-react": "^6.5.0",
6464
"babel-preset-react-optimize": "^1.0.1",
6565
"babel-preset-stage-0": "^6.5.0",
66-
"babel-register": "^6.9.0",
66+
"babel-register": "^6.26.0",
6767
"chai": "^3.5.0",
68-
"chunk-manifest-webpack-plugin": "0.1.0",
68+
"chunk-manifest-webpack-plugin": "^1.1.2",
6969
"coveralls": "^2.11.9",
70-
"css-loader": "^0.23.1",
71-
"css-modules-require-hook": "^4.0.1",
70+
"css-loader": "^0.28.7",
71+
"css-modules-require-hook": "^4.2.2",
7272
"cssnano": "^3.7.0",
7373
"enzyme": "^2.3.0",
7474
"eslint": "^2.11.1",
@@ -78,10 +78,9 @@
7878
"eslint-plugin-jsx-a11y": "^1.3.0",
7979
"eslint-plugin-react": "^5.1.1",
8080
"eventsource-polyfill": "^0.9.6",
81-
"extract-text-webpack-plugin": "^1.0.1",
81+
"extract-text-webpack-plugin": "^3.0.2",
8282
"file-loader": "^0.8.5",
8383
"jsdom": "^9.2.1",
84-
"json-loader": "^0.5.4",
8584
"mock-css-modules": "^1.0.0",
8685
"mockgoose": "^6.0.3",
8786
"nock": "^8.0.0",
@@ -90,7 +89,7 @@
9089
"nyc": "^6.4.4",
9190
"postcss-cssnext": "^2.6.0",
9291
"postcss-focus": "^1.0.0",
93-
"postcss-loader": "^0.9.1",
92+
"postcss-loader": "^2.0.9",
9493
"postcss-reporter": "^1.3.3",
9594
"pre-commit": "^1.1.3",
9695
"react-addons-test-utils": "^15.1.0",
@@ -101,15 +100,15 @@
101100
"redux-devtools-log-monitor": "^1.0.11",
102101
"rimraf": "^2.5.2",
103102
"sinon": "^1.17.4",
104-
"style-loader": "^0.13.1",
103+
"style-loader": "^0.19.1",
105104
"supertest": "^1.2.0",
106105
"url-loader": "^0.5.7",
107-
"webpack": "2.1.0-beta.8",
108-
"webpack-dev-middleware": "^1.6.1",
109-
"webpack-dev-server": "^2.1.0-beta.0",
110-
"webpack-externals-plugin": "^1.0.0",
111-
"webpack-hot-middleware": "^2.10.0",
112-
"webpack-manifest-plugin": "^1.0.1"
106+
"webpack": "^3.10.0",
107+
"webpack-dev-middleware": "^1.12.2",
108+
"webpack-dev-server": "^2.9.7",
109+
"webpack-hot-middleware": "^2.21.0",
110+
"webpack-manifest-plugin": "^1.3.2",
111+
"webpack2-externals-plugin": "^1.0.0"
113112
},
114113
"engines": {
115114
"node": ">=4"

‎webpack.config.babel.js

+38-13
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,57 @@ module.exports = {
1313
libraryTarget: 'commonjs2',
1414
},
1515
resolve: {
16-
extensions: ['', '.js', '.jsx'],
16+
extensions: ['.js', '.jsx'],
1717
modules: [
1818
'client',
1919
'node_modules',
2020
],
2121
},
2222
module: {
23-
loaders: [
23+
rules: [
2424
{
2525
test: /\.css$/,
2626
exclude: /node_modules/,
27-
loader: 'style-loader!css-loader?localIdentName=' + cssModulesIdentName + '&modules&importLoaders=1&sourceMap!postcss-loader',
27+
use: [
28+
{
29+
loader: 'style-loader',
30+
},
31+
{
32+
loader: 'css-loader',
33+
options: {
34+
localIdentName: cssModulesIdentName,
35+
modules: true,
36+
importLoaders: 1,
37+
sourceMap: true,
38+
},
39+
},
40+
{
41+
loader: 'postcss-loader',
42+
options: {
43+
plugins: () => [
44+
postcssFocus(),
45+
cssnext({
46+
browsers: ['last 2 versions', 'IE > 10'],
47+
}),
48+
postcssReporter({
49+
clearMessages: true,
50+
}),
51+
],
52+
},
53+
},
54+
],
2855
},
2956
{
3057
test: /\.jpe?g$|\.gif$|\.png$|\.svg$/i,
31-
loader: 'url-loader?limit=10000',
58+
use: [
59+
{
60+
loader: 'url-loader',
61+
options: {
62+
limit: 10000,
63+
},
64+
},
65+
],
3266
},
3367
],
3468
},
35-
postcss: () => [
36-
postcssFocus(),
37-
cssnext({
38-
browsers: ['last 2 versions', 'IE > 10'],
39-
}),
40-
postcssReporter({
41-
clearMessages: true,
42-
}),
43-
],
4469
};

‎webpack.config.dev.js

+47-23
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,67 @@ module.exports = {
2727
},
2828

2929
resolve: {
30-
extensions: ['', '.js', '.jsx'],
30+
extensions: ['.js', '.jsx'],
3131
modules: [
3232
'client',
3333
'node_modules',
3434
],
3535
},
3636

3737
module: {
38-
loaders: [
38+
rules: [
3939
{
40-
test: /\.css$/,
40+
test: /\.s?css$/,
4141
exclude: /node_modules/,
42-
loader: 'style-loader!css-loader?localIdentName=[name]__[local]__[hash:base64:5]&modules&importLoaders=1&sourceMap!postcss-loader',
43-
}, {
42+
use: [
43+
{
44+
loader: 'style-loader',
45+
},
46+
{
47+
loader: 'css-loader',
48+
options: {
49+
localIdentName: '[name]__[local]__[hash:base64:5]',
50+
modules: true,
51+
importLoaders: 1,
52+
sourceMap: true,
53+
},
54+
},
55+
{
56+
loader: 'postcss-loader',
57+
options: {
58+
plugins: () => [
59+
postcssFocus(),
60+
cssnext({
61+
browsers: ['last 2 versions', 'IE > 10'],
62+
}),
63+
postcssReporter({
64+
clearMessages: true,
65+
}),
66+
],
67+
},
68+
},
69+
],
70+
},
71+
{
4472
test: /\.css$/,
4573
include: /node_modules/,
46-
loaders: ['style-loader', 'css-loader'],
47-
}, {
74+
use: ['style-loader', 'css-loader'],
75+
},
76+
{
4877
test: /\.jsx*$/,
4978
exclude: [/node_modules/, /.+\.config.js/],
50-
loader: 'babel',
51-
}, {
79+
use: 'babel-loader',
80+
},
81+
{
5282
test: /\.(jpe?g|gif|png|svg)$/i,
53-
loader: 'url-loader?limit=10000',
54-
}, {
55-
test: /\.json$/,
56-
loader: 'json-loader',
83+
use: [
84+
{
85+
loader: 'url-loader',
86+
options: {
87+
limit: 10000,
88+
},
89+
},
90+
],
5791
},
5892
],
5993
},
@@ -72,14 +106,4 @@ module.exports = {
72106
}
73107
}),
74108
],
75-
76-
postcss: () => [
77-
postcssFocus(),
78-
cssnext({
79-
browsers: ['last 2 versions', 'IE > 10'],
80-
}),
81-
postcssReporter({
82-
clearMessages: true,
83-
}),
84-
],
85109
};

‎webpack.config.prod.js

+54-32
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,69 @@ module.exports = {
2727
},
2828

2929
resolve: {
30-
extensions: ['', '.js', '.jsx'],
30+
extensions: ['.js', '.jsx'],
3131
modules: [
3232
'client',
3333
'node_modules',
3434
],
3535
},
3636

3737
module: {
38-
loaders: [
38+
rules: [
3939
{
40-
test: /\.css$/,
40+
test: /\.s?css$/,
4141
exclude: /node_modules/,
42-
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?localIdentName=[hash:base64]&modules&importLoaders=1!postcss-loader'),
43-
}, {
42+
use: ExtractTextPlugin.extract({
43+
fallback: 'style-loader',
44+
use: [
45+
{
46+
loader: 'css-loader',
47+
options: {
48+
localIdentName: '[hash:base64]',
49+
modules: true,
50+
importLoaders: 1,
51+
},
52+
},
53+
{
54+
loader: 'postcss-loader',
55+
options: {
56+
plugins: () => [
57+
postcssFocus(),
58+
cssnext({
59+
browsers: ['last 2 versions', 'IE > 10'],
60+
}),
61+
cssnano({
62+
autoprefixer: false,
63+
}),
64+
postcssReporter({
65+
clearMessages: true,
66+
}),
67+
],
68+
},
69+
},
70+
],
71+
}),
72+
},
73+
{
4474
test: /\.css$/,
4575
include: /node_modules/,
46-
loaders: ['style-loader', 'css-loader'],
47-
}, {
76+
use: ['style-loader', 'css-loader'],
77+
},
78+
{
4879
test: /\.jsx*$/,
4980
exclude: /node_modules/,
50-
loader: 'babel',
51-
}, {
81+
use: 'babel-loader',
82+
},
83+
{
5284
test: /\.(jpe?g|gif|png|svg)$/i,
53-
loader: 'url-loader?limit=10000',
54-
}, {
55-
test: /\.json$/,
56-
loader: 'json-loader',
85+
use: [
86+
{
87+
loader: 'url-loader',
88+
options: {
89+
limit: 10000,
90+
},
91+
},
92+
],
5793
},
5894
],
5995
},
@@ -69,31 +105,17 @@ module.exports = {
69105
minChunks: Infinity,
70106
filename: 'vendor.js',
71107
}),
72-
new ExtractTextPlugin('app.[chunkhash].css', { allChunks: true }),
108+
new ExtractTextPlugin({
109+
filename: 'app.[contenthash].css',
110+
allChunks: true,
111+
}),
73112
new ManifestPlugin({
74113
basePath: '/',
75114
}),
76115
new ChunkManifestPlugin({
77116
filename: "chunk-manifest.json",
78117
manifestVariable: "webpackManifest",
79118
}),
80-
new webpack.optimize.UglifyJsPlugin({
81-
compressor: {
82-
warnings: false,
83-
}
84-
}),
85-
],
86-
87-
postcss: () => [
88-
postcssFocus(),
89-
cssnext({
90-
browsers: ['last 2 versions', 'IE > 10'],
91-
}),
92-
cssnano({
93-
autoprefixer: false
94-
}),
95-
postcssReporter({
96-
clearMessages: true,
97-
}),
119+
new webpack.optimize.UglifyJsPlugin(),
98120
],
99121
};

‎webpack.config.server.js

+22-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
var fs = require('fs');
22
var path = require('path');
3-
var ExternalsPlugin = require('webpack-externals-plugin');
3+
var ExternalsPlugin = require('webpack2-externals-plugin');
44

55
module.exports = {
6-
76
entry: path.resolve(__dirname, 'server/server.js'),
87

98
output: {
@@ -19,44 +18,44 @@ module.exports = {
1918
},
2019

2120
resolve: {
22-
extensions: ['', '.js', '.jsx'],
21+
extensions: ['.js', '.jsx'],
2322
modules: [
2423
'client',
2524
'node_modules',
2625
],
2726
},
2827

2928
module: {
30-
loaders: [
29+
rules: [
3130
{
3231
test: /\.js$/,
3332
exclude: /node_modules/,
34-
loader: 'babel-loader',
35-
query: {
36-
presets: [
37-
'react',
38-
'es2015',
39-
'stage-0',
40-
],
41-
plugins: [
42-
[
43-
'babel-plugin-webpack-loaders', {
44-
'config': './webpack.config.babel.js',
45-
"verbose": false
46-
}
47-
]
48-
]
33+
use: {
34+
loader: 'babel-loader',
35+
options: {
36+
presets: [
37+
'react',
38+
'es2015',
39+
'stage-0',
40+
],
41+
plugins: [
42+
[
43+
'babel-plugin-webpack-loaders', {
44+
config: './webpack.config.babel.js',
45+
verbose: false,
46+
},
47+
],
48+
],
49+
},
4950
},
50-
}, {
51-
test: /\.json$/,
52-
loader: 'json-loader',
5351
},
5452
],
5553
},
54+
5655
plugins: [
5756
new ExternalsPlugin({
5857
type: 'commonjs',
59-
include: path.join(__dirname, './node_modules/'),
58+
include: path.join(__dirname, 'node_modules'),
6059
}),
6160
],
6261
};

0 commit comments

Comments
 (0)
Please sign in to comment.