Skip to content
This repository was archived by the owner on May 7, 2022. It is now read-only.

Commit de29c48

Browse files
committed
upgrade:4.1.0
1 parent a10f1f0 commit de29c48

File tree

5 files changed

+1837
-1536
lines changed

5 files changed

+1837
-1536
lines changed

config/webpack.config.dev.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const path = require('path');
55
const webpack = require('webpack');
66
const HtmlWebpackPlugin = require('html-webpack-plugin');
77
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
8-
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
9-
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
108
const eslintFormatter = require('react-dev-utils/eslintFormatter');
119
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
1210
const getClientEnvironment = require('./env');
@@ -17,7 +15,7 @@ const publicUrl = '';
1715
const env = getClientEnvironment(publicUrl);
1816

1917
module.exports = {
20-
devtool: 'cheap-module-source-map',
18+
mode: 'development',
2119
entry: [
2220
require.resolve('./polyfills'),
2321
require.resolve('react-dev-utils/webpackHotDevClient'),
@@ -135,7 +133,6 @@ module.exports = {
135133
],
136134
},
137135
plugins: [
138-
new InterpolateHtmlPlugin(env.raw),
139136
new HtmlWebpackPlugin({
140137
inject: true,
141138
hash: true,
@@ -145,7 +142,6 @@ module.exports = {
145142
new webpack.DefinePlugin(env.stringified),
146143
new webpack.HotModuleReplacementPlugin(),
147144
new CaseSensitivePathsPlugin(),
148-
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
149145
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
150146
],
151147
node: {

config/webpack.config.prod.js

Lines changed: 63 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,25 @@ const autoprefixer = require('autoprefixer');
44
const path = require('path');
55
const webpack = require('webpack');
66
const HtmlWebpackPlugin = require('html-webpack-plugin');
7-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
7+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
88
const ManifestPlugin = require('webpack-manifest-plugin');
9-
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
109
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
1110
const eslintFormatter = require('react-dev-utils/eslintFormatter');
1211
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
1312
const paths = require('./paths');
1413
const getClientEnvironment = require('./env');
1514

1615
const publicPath = paths.servedPath;
17-
const shouldUseRelativeAssetPaths = publicPath === './';
18-
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
1916
const publicUrl = publicPath.slice(0, -1);
2017
const env = getClientEnvironment(publicUrl);
2118

2219
if (env.stringified['process.env'].NODE_ENV !== '"production"') {
2320
throw new Error('Production builds must have NODE_ENV=production.');
2421
}
2522

26-
const cssFilename = 'static/css/[name].[contenthash:8].css';
27-
28-
const extractTextPluginOptions = shouldUseRelativeAssetPaths
29-
?
30-
{ publicPath: Array(cssFilename.split('/').length).join('../') }
31-
: {};
32-
3323
module.exports = {
24+
mode: 'production',
3425
bail: true,
35-
devtool: shouldUseSourceMap ? 'source-map' : false,
3626
entry: [require.resolve('./polyfills'), paths.appIndexJs],
3727
output: {
3828
path: paths.appBuild,
@@ -100,55 +90,43 @@ module.exports = {
10090
},
10191
{
10292
test: /\.(less|css)$/,
103-
loader: ExtractTextPlugin.extract(
104-
Object.assign(
105-
{
106-
fallback: {
107-
loader: require.resolve('style-loader'),
108-
options: {
109-
hmr: false,
110-
},
111-
},
112-
use: [
113-
{
114-
loader: require.resolve('css-loader'),
115-
options: {
116-
importLoaders: 1,
117-
minimize: true,
118-
sourceMap: shouldUseSourceMap,
119-
modules: true,
120-
localIdentName: '[local]--[hash:base64:5]'
121-
},
122-
},
123-
{
124-
loader: require.resolve('postcss-loader'),
125-
options: {
126-
ident: 'postcss',
127-
plugins: () => [
128-
require('postcss-flexbugs-fixes'),
129-
autoprefixer({
130-
browsers: [
131-
'>1%',
132-
'last 4 versions',
133-
'Firefox ESR',
134-
'not ie < 9', // React doesn't support IE8 anyway
135-
],
136-
flexbox: 'no-2009',
137-
}),
138-
require('postcss-pxtorem')({
139-
rootValue: 75,
140-
propList: ['*']
141-
}),
142-
require('precss')
143-
],
144-
},
145-
},
146-
require.resolve('less-loader')
93+
use: [
94+
MiniCssExtractPlugin.loader,
95+
{
96+
loader: require.resolve ('css-loader'),
97+
options: {
98+
importLoaders: 1,
99+
minimize: true,
100+
sourceMap: true,
101+
modules: true,
102+
localIdentName: '[local]--[hash:base64:5]'
103+
}
104+
},
105+
{
106+
loader: require.resolve('postcss-loader'),
107+
options: {
108+
ident: 'postcss',
109+
plugins: () => [
110+
require('postcss-flexbugs-fixes'),
111+
autoprefixer({
112+
browsers: [
113+
'>1%',
114+
'last 4 versions',
115+
'Firefox ESR',
116+
'not ie < 9', // React doesn't support IE8 anyway
117+
],
118+
flexbox: 'no-2009',
119+
}),
120+
require('postcss-pxtorem')({
121+
rootValue: 75,
122+
propList: ['*']
123+
}),
124+
require('precss')
147125
],
148126
},
149-
extractTextPluginOptions
150-
)
151-
),
127+
},
128+
require.resolve('less-loader')
129+
]
152130
},
153131
{
154132
loader: require.resolve('file-loader'),
@@ -161,11 +139,33 @@ module.exports = {
161139
},
162140
],
163141
},
142+
optimization: {
143+
splitChunks: {
144+
chunks: 'all',
145+
minSize: 30000,
146+
maxSize: 0,
147+
minChunks: 1,
148+
maxAsyncRequests: 5,
149+
maxInitialRequests: 3,
150+
automaticNameDelimiter: '~',
151+
name: true,
152+
cacheGroups: {
153+
vendors: {
154+
test: /[\\/]node_modules[\\/]/,
155+
priority: -10
156+
},
157+
default: {
158+
minChunks: 2,
159+
priority: -20,
160+
reuseExistingChunk: true
161+
}
162+
}
163+
}
164+
},
164165
plugins: [
165-
new InterpolateHtmlPlugin(env.raw),
166166
new HtmlWebpackPlugin({
167167
inject: true,
168-
hash: true,
168+
hash: true,
169169
template: paths.appHtml,
170170
minify: {
171171
removeComments: true,
@@ -181,22 +181,8 @@ module.exports = {
181181
},
182182
}),
183183
new webpack.DefinePlugin(env.stringified),
184-
new webpack.optimize.UglifyJsPlugin({
185-
compress: {
186-
warnings: false,
187-
comparisons: false,
188-
},
189-
mangle: {
190-
safari10: true,
191-
},
192-
output: {
193-
comments: false,
194-
ascii_only: true,
195-
},
196-
sourceMap: shouldUseSourceMap,
197-
}),
198-
new ExtractTextPlugin({
199-
filename: cssFilename,
184+
new MiniCssExtractPlugin({
185+
filename: 'static/css/[contenthash].css',
200186
}),
201187
new ManifestPlugin({
202188
fileName: 'asset-manifest.json',

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-webpack",
3-
"version": "4.0.0",
3+
"version": "4.1.0",
44
"scripts": {
55
"start": "node scripts/start.js",
66
"build": "node scripts/build.js",
@@ -26,21 +26,21 @@
2626
"dotenv-expand": "4.2.0",
2727
"eslint": "4.10.0",
2828
"eslint-config-react-app": "^2.1.0",
29-
"eslint-loader": "1.9.0",
29+
"eslint-loader": "^2.1.0",
3030
"eslint-plugin-flowtype": "2.39.1",
3131
"eslint-plugin-import": "2.8.0",
3232
"eslint-plugin-jsx-a11y": "5.1.1",
3333
"eslint-plugin-react": "7.4.0",
34-
"extract-text-webpack-plugin": "^3.0.2",
35-
"file-loader": "1.1.5",
34+
"file-loader": "2.0.0",
3635
"fs-extra": "3.0.1",
3736
"history": "^4.7.2",
38-
"html-webpack-plugin": "2.29.0",
37+
"html-webpack-plugin": "^4.0.0-alpha",
3938
"http-proxy-middleware": "^0.18.0",
4039
"immutable": "^3.8.2",
4140
"jest": "20.0.4",
4241
"less": "^3.0.4",
4342
"less-loader": "^4.1.0",
43+
"mini-css-extract-plugin": "^0.4.2",
4444
"object-assign": "4.1.1",
4545
"postcss-flexbugs-fixes": "3.2.0",
4646
"postcss-loader": "2.0.8",
@@ -65,11 +65,11 @@
6565
"resolve": "1.6.0",
6666
"serve": "^6.5.6",
6767
"style-loader": "0.19.0",
68-
"sw-precache-webpack-plugin": "0.11.4",
68+
"sw-precache-webpack-plugin": "0.11.5",
6969
"url-loader": "0.6.2",
70-
"webpack": "3.8.1",
71-
"webpack-dev-server": "2.9.4",
72-
"webpack-manifest-plugin": "1.3.2",
70+
"webpack": "4.17.1",
71+
"webpack-dev-server": "3.1.5",
72+
"webpack-manifest-plugin": "2.0.0",
7373
"whatwg-fetch": "2.0.3"
7474
},
7575
"jest": {

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
66
<meta name="theme-color" content="#000000">
7-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
8-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
7+
<link rel="manifest" href="/manifest.json">
8+
<link rel="shortcut icon" href="/favicon.ico">
99
<title>react-redux-webpack</title>
1010
</head>
1111
<body>

0 commit comments

Comments
 (0)