Skip to content

Commit 8685263

Browse files
committed
Updates to webpack 3 - check style clean up, and other lib update
1 parent 4f6eae6 commit 8685263

File tree

2 files changed

+53
-52
lines changed

2 files changed

+53
-52
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"license": "MIT",
1818
"devDependencies": {
1919
"babel-core": "^6.25.0",
20-
"babel-loader": "^7.0.0",
20+
"babel-loader": "^7.1.0",
2121
"babel-plugin-inferno": "^3.1.0",
2222
"babel-preset-es2015": "^6.22.0",
2323
"compression-webpack-plugin": "^0.4.0",
@@ -29,13 +29,13 @@
2929
"extract-text-webpack-plugin": "^2.1.2",
3030
"file-loader": "^0.11.2",
3131
"html-loader": "^0.4.4",
32-
"html-webpack-plugin": "^2.28.0",
32+
"html-webpack-plugin": "^2.29.0",
3333
"less": "^2.7.2",
3434
"less-loader": "^4.0.4",
3535
"style-loader": "^0.18.2",
3636
"url-loader": "^0.5.9",
37-
"webpack": "^2.6.1",
38-
"webpack-dev-server": "^2.4.4",
37+
"webpack": "^3.0.0",
38+
"webpack-dev-server": "^2.5.0",
3939
"xo": "^0.18.2"
4040
},
4141
"dependencies": {

webpack.config.js

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,59 +13,59 @@ module.exports = function (env) {
1313
const plugins = [
1414
new webpack.optimize.CommonsChunkPlugin({
1515
names: ['inferno.vendor'],
16-
chunks: ["inferno"],
17-
minChunks: function(module) {
16+
chunks: ['inferno'],
17+
minChunks: function (module) {
1818
return isExternal(module)
19-
},
19+
}
2020
}),
2121
new webpack.optimize.CommonsChunkPlugin({
22-
name: "purecss.vendor",
23-
chunks: ["purecss"],
24-
minChunks: function(module, count){
22+
name: 'purecss.vendor',
23+
chunks: ['purecss'],
24+
minChunks: function (module) {
2525
return isExternal(module)
26-
},
26+
}
2727
}),
2828
new webpack.optimize.CommonsChunkPlugin({
29-
name: "mincss.vendor",
30-
chunks: ["mincss"],
31-
minChunks: function(module, count){
29+
name: 'mincss.vendor',
30+
chunks: ['mincss'],
31+
minChunks: function (module) {
3232
return isExternal(module)
33-
},
33+
}
3434
}),
3535
new webpack.optimize.CommonsChunkPlugin({
36-
name: "photo.vendor",
37-
chunks: ["photo"],
38-
minChunks: function(module, count){
36+
name: 'photo.vendor',
37+
chunks: ['photo'],
38+
minChunks: function (module) {
3939
return isExternal(module)
40-
},
40+
}
4141
}),
4242
new webpack.DefinePlugin({
43-
'process.env': { NODE_ENV: JSON.stringify(nodeEnv) }
43+
'process.env': {NODE_ENV: JSON.stringify(nodeEnv)}
4444
}),
4545
new webpack.NamedModulesPlugin(),
4646
new HtmlWebpackPlugin({
4747
filename: 'inferno.html',
48-
title: 'Inferno',
49-
template: 'inferno/index-template.html',
50-
chunks: ['inferno.vendor', 'inferno'],
48+
title: 'Inferno',
49+
template: 'inferno/index-template.html',
50+
chunks: ['inferno.vendor', 'inferno']
5151
}),
5252
new HtmlWebpackPlugin({
5353
filename: 'purecss.html',
5454
title: 'PureCSS',
5555
template: 'purecss/index-template.html',
56-
chunks: ['purecss.vendor', 'purecss'],
57-
}),
56+
chunks: ['purecss.vendor', 'purecss']
57+
}),
5858
new HtmlWebpackPlugin({
5959
filename: 'mincss.html',
6060
title: 'MINCSS',
6161
template: 'mincss/index-template.html',
62-
chunks: ['mincss.vendor', 'mincss'],
62+
chunks: ['mincss.vendor', 'mincss']
6363
}),
6464
new HtmlWebpackPlugin({
6565
filename: 'photo.html',
6666
title: 'Photo',
6767
template: 'photo/index-template.html',
68-
chunks: ['photo.vendor', 'photo'],
68+
chunks: ['photo.vendor', 'photo']
6969
})
7070
]
7171

@@ -85,13 +85,14 @@ module.exports = function (env) {
8585
sourceMap: true
8686
}),
8787
new CompressionPlugin({
88-
asset: "[path].gz[query]",
89-
algorithm: "gzip",
90-
test: /\.js$|\.css$|\.html$|\.eot$|\.svg$|\.ttf$|\.woff$/,
91-
threshold: 1024,
92-
minRatio: 0.8
93-
}),
94-
new ExtractTextPlugin("[name].css")
88+
asset: '[path].gz[query]',
89+
algorithm: 'gzip',
90+
test: /\.js$|\.css$|\.html$|\.eot$|\.svg$|\.ttf$|\.woff$/,
91+
threshold: 1024,
92+
minRatio: 0.8
93+
}),
94+
new ExtractTextPlugin('[name].css'),
95+
new webpack.optimize.ModuleConcatenationPlugin()
9596
)
9697
} else {
9798
plugins.push(
@@ -110,7 +111,7 @@ module.exports = function (env) {
110111
},
111112
output: {
112113
path: __dirname + '/static',
113-
filename: '[name].js',
114+
filename: '[name].js'
114115
},
115116
module: {
116117
rules: [
@@ -120,8 +121,8 @@ module.exports = function (env) {
120121
loader: 'html-loader',
121122
query: {
122123
name: '[name].[ext]'
123-
},
124-
},
124+
}
125+
}
125126
},
126127
{
127128
test: /\.less$/,
@@ -133,23 +134,23 @@ module.exports = function (env) {
133134
},
134135
{
135136
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
136-
loader: isProd ? "file-loader?limit=10000&mimetype=application/font-woff" : "url-loader?limit=10000&mimetype=application/font-woff"
137+
loader: isProd ? 'file-loader?limit=10000&mimetype=application/font-woff' : 'url-loader?limit=10000&mimetype=application/font-woff'
137138
},
138139
{
139140
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
140-
loader: isProd ? "file-loader" : "url-loader"
141+
loader: isProd ? 'file-loader' : 'url-loader'
141142
},
142143
{
143144
test: /\.(jpg|jpeg|png)$/,
144-
loader: isProd ? "file-loader" : "url-loader"
145+
loader: isProd ? 'file-loader' : 'url-loader'
145146
},
146147
{
147148
test: /\.(js|jsx)$/,
148149
use: [
149150
'babel-loader'
150-
],
151-
},
152-
],
151+
]
152+
}
153+
]
153154
},
154155
resolve: {
155156
extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.jsx'],
@@ -164,12 +165,12 @@ module.exports = function (env) {
164165
performance: isProd && {
165166
maxAssetSize: 100000,
166167
maxEntrypointSize: 100000,
167-
hints: 'warning',
168+
hints: 'warning'
168169
},
169170

170171
stats: {
171172
colors: {
172-
green: '\u001b[32m',
173+
green: '\u001b[32m'
173174
}
174175
},
175176

@@ -191,15 +192,15 @@ module.exports = function (env) {
191192
version: false,
192193
warnings: true,
193194
colors: {
194-
green: '\u001b[32m',
195+
green: '\u001b[32m'
195196
}
196-
},
197+
}
197198
}
198199
}
199200
}
200201

201202
function isExternal(module) {
202-
var userRequest = module.userRequest
203+
const userRequest = module.userRequest
203204

204205
if (typeof userRequest !== 'string') {
205206
return false
@@ -227,12 +228,12 @@ function lessNonExtractTextLoader() {
227228

228229
function extractTextLoader() {
229230
return ExtractTextPlugin.extract({
230-
fallback: 'style-loader', use: 'css-loader'
231-
})
231+
fallback: 'style-loader', use: 'css-loader'
232+
})
232233
}
233234

234235
function lessExtractTextLoader() {
235236
return ExtractTextPlugin.extract({
236-
fallback: 'style-loader', use: 'css-loader!less-loader'
237-
})
237+
fallback: 'style-loader', use: 'css-loader!less-loader'
238+
})
238239
}

0 commit comments

Comments
 (0)