Skip to content

Commit 3461287

Browse files
authored
Update webpack to the latest version 🚀 (#92)
* chore(package): update webpack to version 4.6.0 Closes #78 * chore(package): Upgrade to latest webpack and dev server Closes #82
1 parent 24a8dc6 commit 3461287

File tree

3 files changed

+364
-265
lines changed

3 files changed

+364
-265
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"author": "pandah <hrusikesh.panda@dowjones.com>",
2424
"license": "MIT",
2525
"scripts": {
26-
"build": "rimraf dist/**/* && webpack --config webpack.config.js --bail",
27-
"build:docs": "yarn build && webpack --config docs/webpack.config.js --bail",
26+
"build": "rimraf dist/**/* && webpack --config webpack.config.js --bail --mode=production",
27+
"build:docs": "yarn build && webpack --config docs/webpack.config.js --bail --mode=production",
2828
"commit": "git-cz",
2929
"commitmsg": "commitlint -e $GIT_PARAMS",
3030
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
31-
"demo": "webpack-dev-server --config docs/webpack.config.js",
31+
"demo": "webpack-dev-server --mode=development --config docs/webpack.config.js",
3232
"prepublishOnly": "npm run build",
3333
"lint": "eslint src docs webpack.config.js && stylelint \"src/**/*.css\" --fix",
3434
"format": "prettier-eslint \"src/**/*.js\" \"docs/**/*.js\" webpack.config.js",
@@ -69,13 +69,13 @@
6969
"eslint-plugin-import": "^2.9.0",
7070
"eslint-plugin-jsx-a11y": "^6.0.3",
7171
"eslint-plugin-react": "^7.7.0",
72-
"extract-text-webpack-plugin": "^3.0.2",
7372
"github-markdown-css": "^2.10.0",
7473
"husky": "^0.14.3",
7574
"ignore-styles": "^5.0.1",
7675
"jsdom": "^11.2.0",
7776
"jsdom-global": "^3.0.2",
7877
"marked": "^0.3.17",
78+
"mini-css-extract-plugin": "^0.4.0",
7979
"nyc": "^11.2.1",
8080
"open": "^0.0.5",
8181
"postcss": "^6.0.16",
@@ -97,10 +97,10 @@
9797
"stylelint-config-standard": "^18.0.0",
9898
"travis-deploy-once": "^4.3.2",
9999
"url-loader": "^1.0.1",
100-
"webpack": "^3.5.6",
100+
"webpack": "^4.6.0",
101101
"webpack-bundle-analyzer": "^2.9.2",
102102
"webpack-cli": "^2.0.9",
103-
"webpack-dev-server": "^2.9.4"
103+
"webpack-dev-server": "^3.1.3"
104104
},
105105
"peerDependencies": {
106106
"react": "^15.0.0 || ^16.0.0"

webpack.config.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path')
22
const webpack = require('webpack')
3-
const ExtractTextPlugin = require('extract-text-webpack-plugin')
3+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
44
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
55

66
module.exports = {
@@ -23,12 +23,16 @@ module.exports = {
2323
},
2424
plugins: [
2525
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
26-
new ExtractTextPlugin('styles.css'),
27-
new webpack
28-
.optimize
29-
.UglifyJsPlugin({ sourceMap: true, exclude: /node_modules/ }),
26+
new MiniCssExtractPlugin({
27+
// Options similar to the same options in webpackOptions.output
28+
// both options are optional
29+
filename: 'styles.css',
30+
chunkFilename: '[id].css'
31+
}),
3032
new BundleAnalyzerPlugin({
31-
analyzerMode: 'static', openAnalyzer: false, generateStatsFile: true
33+
analyzerMode: 'static',
34+
openAnalyzer: false,
35+
generateStatsFile: true
3236
})
3337
],
3438
module: {
@@ -38,23 +42,23 @@ module.exports = {
3842
loaders: ['babel-loader'],
3943
include: path.join(__dirname, 'src'),
4044
exclude: /node_modules/
41-
}, {
45+
},
46+
{
4247
test: /\.css$/,
43-
use: ExtractTextPlugin.extract({
44-
use: [
45-
{
46-
loader: 'css-loader',
47-
options: {
48-
localIdentName: 'react-dropdown-tree-select__[local]--[hash:base64:5]',
49-
importLoaders: 1,
50-
minimize: true
51-
}
52-
},
53-
{ loader: 'postcss-loader' }
54-
]
55-
}),
5648
include: /src/,
57-
exclude: /node_modules/
49+
exclude: /node_modules/,
50+
use: [
51+
MiniCssExtractPlugin.loader,
52+
{
53+
loader: 'css-loader',
54+
options: {
55+
localIdentName: 'react-dropdown-tree-select__[local]--[hash:base64:5]',
56+
importLoaders: 1,
57+
minimize: true
58+
}
59+
},
60+
{ loader: 'postcss-loader' }
61+
]
5862
}
5963
]
6064
}

0 commit comments

Comments
 (0)