Skip to content

Commit 539f777

Browse files
committed
Update examples build process
1 parent 9c1330e commit 539f777

File tree

8 files changed

+107
-99
lines changed

8 files changed

+107
-99
lines changed

examples/canvas/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
start:
2-
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js
2+
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js --mode=development
33

44
build: clean
5-
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production
5+
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production --mode=production
66
@ cp public/*.css build/
77

88
clean:

examples/chatbot/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
start:
2-
@ $$(npm bin)/webpack-dev-server --config ./webpack.config.js
2+
@ $$(npm bin)/webpack-dev-server --config ./webpack.config.js --mode=development
33

44
.PHONY: start

examples/painter/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
start:
2-
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js
2+
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js --mode=development
33

44
build: clean
5-
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production
5+
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production --mode=production
66
@ cp public/*.css build/
77

88
clean:

examples/react-router/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
start:
2-
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js
2+
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js --mode=development
33

44
build: clean
5-
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production
5+
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production --mode=production
66
@ cp public/*.css build/
77

88
clean:

examples/simple-svg/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
start:
2-
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js
2+
@ $$(npm bin)/webpack-dev-server --config ../webpack.config.js --mode=development
33

44
build: clean
5-
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production
5+
@ $$(npm bin)/webpack -p --config ../webpack.config.js --env=production --mode=production
66
@ cp public/*.css build/
77

88
clean:

examples/webpack.config.js

+5-58
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ module.exports = function(env) {
1515

1616
process.env.BABEL_ENV = isDev ? 'development' : 'production'
1717

18-
let config = {
18+
return {
1919
context: root,
2020

21-
devtool: 'source-map',
21+
devtool: isDev ? 'cheap-module-inline-source-map' : 'source-map',
2222

2323
entry: {
2424
application: ['./app/boot.js']
@@ -38,84 +38,31 @@ module.exports = function(env) {
3838
},
3939

4040
module: {
41-
loaders: [
41+
rules: [
4242
{
43-
test: /\.jsx*/,
43+
test: /\.js$/,
4444
loader: 'babel-loader',
4545
exclude: /node_modules/,
4646
options: {
47-
cacheDirectory: '.babel-cache',
48-
plugins: [
49-
'react-hot-loader/babel',
50-
['transform-runtime', { polyfill: false }]
51-
]
47+
plugins: [['transform-runtime', { polyfill: false }]]
5248
}
5349
}
5450
]
5551
},
5652

5753
plugins: [
58-
new Webpack.DefinePlugin({
59-
'process.env.NODE_ENV': JSON.stringify(
60-
isDev ? 'development' : 'production'
61-
)
62-
}),
6354
new HtmlWebpackPlugin({
6455
inject: true,
6556
template: resolve(root, 'public/index.html')
66-
}),
67-
new Webpack.optimize.CommonsChunkPlugin({
68-
name: 'vendor',
69-
minChunks: function(module) {
70-
var context = module.context
71-
72-
if (context == null) {
73-
return false
74-
}
75-
76-
return (
77-
context.includes('node_modules') ||
78-
context.includes('microcosm/src')
79-
)
80-
}
8157
})
8258
],
8359

84-
node: {
85-
global: true,
86-
console: false,
87-
process: false,
88-
Buffer: false,
89-
__filename: 'mock',
90-
__dirname: 'mock',
91-
setImmediate: false
92-
},
93-
9460
devServer: {
95-
hot: isDev,
9661
contentBase: resolve(root, 'public'),
9762
publicPath: '/',
9863
compress: true,
9964
historyApiFallback: true,
10065
port: PORT
10166
}
10267
}
103-
104-
if (isDev) {
105-
config.devtool = 'cheap-module-inline-source-map'
106-
107-
config.entry['application'].unshift('react-hot-loader/patch')
108-
109-
config.entry['dev'] = [
110-
'webpack-dev-server/client?http://localhost:' + PORT,
111-
'webpack/hot/only-dev-server'
112-
]
113-
114-
config.plugins.unshift(
115-
new Webpack.HotModuleReplacementPlugin(),
116-
new Webpack.NamedModulesPlugin()
117-
)
118-
}
119-
120-
return config
12168
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"axios": "^0.18.0",
4040
"babel-core": "^6.26.0",
4141
"babel-eslint": "^10.0.1",
42-
"babel-loader": "^8.0.4",
42+
"babel-loader": "^7.0.0",
4343
"babel-plugin-transform-runtime": "^6.23.0",
4444
"babel-polyfill": "^6.26.0",
4545
"babel-preset-es2015": "^6.24.1",
@@ -81,6 +81,7 @@
8181
"rollup-plugin-uglify": "^6.0.0",
8282
"uid": "^0.0.2",
8383
"webpack": "^4.27.1",
84+
"webpack-cli": "^3.1.2",
8485
"webpack-dev-server": "^3.1.10",
8586
"zen-observable": "~0.5.2"
8687
},

0 commit comments

Comments
 (0)