Skip to content

Commit 3e38920

Browse files
author
Edward Xiao
committed
modify webpack config
1 parent 121832f commit 3e38920

File tree

3 files changed

+59
-34
lines changed

3 files changed

+59
-34
lines changed

webpack/base.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const path = require('path');
33
const PATH = require('./build_path');
44
const WebpackAssetsManifest = require('webpack-assets-manifest');
55
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6-
const HtmlWebpackPlugin = require('html-webpack-plugin');
76
var config = (module.exports = {
87
context: PATH.ROOT_PATH,
98
entry: {
@@ -182,7 +181,6 @@ var config = (module.exports = {
182181
compress: true,
183182
disableHostCheck: true,
184183
historyApiFallback: true,
185-
186184
host: '0.0.0.0',
187185
port: 9000,
188186
},
@@ -200,24 +198,5 @@ var config = (module.exports = {
200198
new WebpackAssetsManifest({
201199
fileName: 'manifest-rev.json',
202200
}),
203-
new HtmlWebpackPlugin({
204-
template: PATH.HTML_PATH + '/layout.html',
205-
title: 'react-inputs-validation',
206-
page: 'index',
207-
filename: 'index.html',
208-
hash: false,
209-
chunksSortMode: function(chunk1, chunk2) {
210-
var orders = ['index'];
211-
var order1 = orders.indexOf(chunk1.names[0]);
212-
var order2 = orders.indexOf(chunk2.names[0]);
213-
if (order1 > order2) {
214-
return 1;
215-
} else if (order1 < order2) {
216-
return -1;
217-
} else {
218-
return 0;
219-
}
220-
},
221-
}),
222201
],
223202
});

webpack/development.config.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
const base = require('./base.js');
2+
const PATH = require('./build_path');
23
const objectAssign = require('object-assign');
34
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5+
const HtmlWebpackPlugin = require('html-webpack-plugin');
46
const webpack = require('webpack');
57
const PATH = require('./build_path');
68
const config = objectAssign(base, {
79
mode: 'development',
810
output: {
911
publicPath: '/',
10-
filename: '[name].js'
11-
}
12+
filename: '[name].js',
13+
},
1214
});
13-
config.plugins.push(new MiniCssExtractPlugin({ filename: 'css/[name].css' }));
15+
config.plugins.push(
16+
new MiniCssExtractPlugin({ filename: 'css/[name].css' }),
17+
new HtmlWebpackPlugin({
18+
template: PATH.HTML_PATH + '/layout.html',
19+
title: 'react-inputs-validation',
20+
page: 'index',
21+
filename: 'index.html',
22+
hash: false,
23+
chunksSortMode: function(chunk1, chunk2) {
24+
var orders = ['index'];
25+
var order1 = orders.indexOf(chunk1.names[0]);
26+
var order2 = orders.indexOf(chunk2.names[0]);
27+
if (order1 > order2) {
28+
return 1;
29+
} else if (order1 < order2) {
30+
return -1;
31+
} else {
32+
return 0;
33+
}
34+
},
35+
}),
36+
);
1437
module.exports = config;

webpack/production.config.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,55 @@
11
const base = require('./base.js');
2+
const PATH = require('./build_path');
23
const objectAssign = require('object-assign');
34
const webpack = require('webpack');
5+
const HtmlWebpackPlugin = require('html-webpack-plugin');
46
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
57
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
68

79
const config = objectAssign(base, {
810
mode: 'production',
911
devtool: 'cheap-source-map',
1012
output: {
11-
publicPath: '/',
12-
filename: '[name]-[chunkhash].js'
13+
publicPath: '/react-inputs-validation/dist/',
14+
filename: '[name]-[chunkhash].js',
1315
},
1416
optimization: {
1517
minimizer: [
1618
new UglifyJSPlugin({
1719
uglifyOptions: {
1820
output: {
19-
comments: false
21+
comments: false,
2022
},
2123
compress: {
22-
warnings: false
23-
}
24-
}
25-
})
26-
]
27-
}
24+
warnings: false,
25+
},
26+
},
27+
}),
28+
],
29+
},
2830
});
2931

30-
config.plugins.push(new MiniCssExtractPlugin({ filename: 'css/[name]-[hash].css' }));
32+
config.plugins.push(
33+
new MiniCssExtractPlugin({ filename: 'css/[name]-[hash].css' }),
34+
new HtmlWebpackPlugin({
35+
template: PATH.HTML_PATH + '/layout.html',
36+
title: 'react-inputs-validation',
37+
page: 'index',
38+
filename: '../index.html',
39+
hash: false,
40+
chunksSortMode: function(chunk1, chunk2) {
41+
var orders = ['index'];
42+
var order1 = orders.indexOf(chunk1.names[0]);
43+
var order2 = orders.indexOf(chunk2.names[0]);
44+
if (order1 > order2) {
45+
return 1;
46+
} else if (order1 < order2) {
47+
return -1;
48+
} else {
49+
return 0;
50+
}
51+
},
52+
}),
53+
);
3154

3255
module.exports = config;

0 commit comments

Comments
 (0)