Skip to content

Commit 6bf7633

Browse files
author
Knut Behrends
committed
attempt to include manually changes from PR coryhouse#7
1 parent 2e2491d commit 6bf7633

File tree

4 files changed

+75
-27
lines changed

4 files changed

+75
-27
lines changed

.babelrc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{
2-
"presets": [
3-
"latest"
4-
]
2+
"presets": ["env"],
3+
"env": {
4+
"production": {
5+
"presets": [
6+
[
7+
"env",
8+
{
9+
"es2015": {
10+
"modules": false
11+
}
12+
}
13+
]
14+
]
15+
}
16+
}
517
}

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"name": "javascript-development-environment",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "JavaScript development environment",
55
"scripts": {
66
"prestart": "babel-node buildScripts/startMessage.js",
7-
"start": "npm-run-all --parallel security-check open:src lint:watch test:watch",
8-
"start-mocked": "npm-run-all --parallel security-check open:src lint:watch test:watch start-mockapi",
7+
"start": "npm-run-all open:src lint:watch test:watch",
8+
"start-mocked": "npm-run-all open:src lint:watch test:watch start-mockapi",
99
"open:src": "babel-node buildScripts/srcServer.js",
1010
"lint": "esw webpack.config.* src buildScripts --color",
1111
"lint:watch": "npm run lint -- --watch",
12-
"security-check": "nsp check",
1312
"localtunnel": "lt --port 3000",
1413
"share": "npm-run-all --parallel open:src localtunnel",
1514
"test": "mocha --reporter progress buildScripts/testSetup.js \"src/**/*.test.js\"",
@@ -49,15 +48,14 @@
4948
"eslint-watch": "^3.1.5",
5049
"express": "^4.16.3",
5150
"extract-text-webpack-plugin": "^3.0.2",
52-
"html-webpack-plugin": "2.22.0",
51+
"html-webpack-plugin": "3.2.0",
5352
"jsdom": "^11.11.0",
5453
"json-schema-faker": "^0.5.0-rc15",
5554
"json-server": "^0.14.0",
5655
"localtunnel": "^1.9.0",
5756
"mocha": "^5.2.0",
5857
"nock": "^9.6.1",
5958
"npm-run-all": "^4.1.3",
60-
"nsp": "^3.2.1",
6159
"numeral": "^2.0.6",
6260
"open": "0.0.5",
6361
"rimraf": "^2.6.2",

webpack.config.dev.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import webpack from 'webpack';
12
import path from 'path';
23
import HtmlWebpackPlugin from 'html-webpack-plugin';
34

45
export default {
5-
debug: true,
6+
mode: 'development',
7+
resolve: {
8+
extensions: ['*', '.js', '.jsx', '.json']
9+
},
610
devtool: 'inline-source-map',
7-
noInfo: false,
11+
812
entry: [path.resolve(__dirname, 'src/index')],
913
target: 'web',
1014
output: {
@@ -13,16 +17,22 @@ export default {
1317
filename: 'bundle.js'
1418
},
1519
plugins: [
20+
new webpack.LoaderOptionsPlugin({
21+
minimize: false,
22+
debug: true,
23+
noInfo: true // set to false to see a list of every file being bundled.
24+
}),
25+
1626
// Create HTML file that includes reference to bundled JS.
1727
new HtmlWebpackPlugin({
1828
template: 'src/index.html',
1929
inject: true
2030
})
2131
],
2232
module: {
23-
loaders: [
24-
{ test: /\.js$/, exclude: /node_modules/, loaders: ['babel'] },
25-
{ test: /\.css$/, loaders: ['style', 'css'] }
33+
rules: [
34+
{ test: /\.js$/, exclude: /node_modules/, loaders: ['babel-loader'] },
35+
{ test: /\.css$/, loaders: ['style-loader', 'css-loader'] }
2636
]
2737
}
2838
};

webpack.config.prod.js

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import path from 'path';
33
import HtmlWebpackPlugin from 'html-webpack-plugin';
44
import WebpackMd5Hash from 'webpack-md5-hash';
55
import ExtractTextPlugin from 'extract-text-webpack-plugin';
6+
//debug: true,
7+
//noInfo: false,
68

79
export default {
8-
debug: true,
10+
mode: 'production',
11+
resolve: {
12+
extensions: ['*', '.js', '.jsx', '.json']
13+
},
914
devtool: 'source-map',
10-
noInfo: false,
1115
entry: {
1216
vendor: path.resolve(__dirname, 'src/vendor'),
1317
main: path.resolve(__dirname, 'src/index')
@@ -18,19 +22,39 @@ export default {
1822
publicPath: '/',
1923
filename: '[name].[chunkhash].js'
2024
},
25+
// Webpack 4 removed the commonsChunkPlugin. Use optimization.splitChunks instead.
26+
optimization: {
27+
splitChunks: {
28+
cacheGroups: {
29+
commons: {
30+
test: /[\\/]node_modules[\\/]/,
31+
name: 'vendor',
32+
chunks: 'all'
33+
}
34+
}
35+
}
36+
},
2137
plugins: [
38+
// Global loader configuration
39+
new webpack.LoaderOptionsPlugin({
40+
minimize: true,
41+
debug: false,
42+
noInfo: true // set to false to see a list of every file being bundled.
43+
}),
44+
2245
// (separate css and js)
2346
// Generate an external css file with a hash in the filename
24-
new ExtractTextPlugin('[name].[contenthash].css'),
25-
47+
//new ExtractTextPlugin('[name].[contenthash].css'),
48+
new ExtractTextPlugin('[name].[md5:contenthash:hex:20].css'),
2649
// Hash the files using MD5 so that their names change when the content changes.
2750
new WebpackMd5Hash(),
2851

2952
// Use CommonsChunkPlugin to create a separate bundle
3053
// of vendor libraries so that they're cached separately.
31-
new webpack.optimize.CommonsChunkPlugin({
32-
name: 'vendor'
33-
}),
54+
// No longer used for Webpack 4. See optimization.splitChunks above instead.
55+
// new webpack.optimize.CommonsChunkPlugin({
56+
// name: 'vendor'
57+
// }),
3458

3559
// Create HTML file that includes reference to bundled JS.
3660
new HtmlWebpackPlugin({
@@ -51,18 +75,22 @@ export default {
5175
// Properties you define here are available in index.html
5276
// using htmlWebpackPlugin.options.varName
5377
trackJSToken: 'INSERT YOUR TOKEN HERE'
54-
}),
78+
})
5579

5680
// Eliminate duplicate packages when generating bundle
57-
new webpack.optimize.DedupePlugin(),
81+
//new webpack.optimize.DedupePlugin()
5882

83+
// Code is automatically minified in prod mode as of Webpack 4, so removing this.
5984
// Minify JS
60-
new webpack.optimize.UglifyJsPlugin()
85+
//new webpack.optimize.UglifyJsPlugin()
6186
],
6287
module: {
63-
loaders: [
64-
{ test: /\.js$/, exclude: /node_modules/, loaders: ['babel'] },
65-
{ test: /\.css$/, loader: ExtractTextPlugin.extract('css?sourceMap') } // extra param is a hint to webpack
88+
rules: [
89+
{ test: /\.js$/, exclude: /node_modules/, loaders: ['babel-loader'] },
90+
{
91+
test: /\.css$/,
92+
loader: ExtractTextPlugin.extract('css-loader?sourceMap')
93+
} // extra param is a hint to webpack
6694
]
6795
}
6896
};

0 commit comments

Comments
 (0)