Skip to content

Commit ff41b15

Browse files
committed
update webpack,sass,pwa(sw-precache->workbox),postcss
1 parent e31adc2 commit ff41b15

File tree

6 files changed

+2821
-1465
lines changed

6 files changed

+2821
-1465
lines changed

build/styleLoaderConf.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ const postcssLoader = {
77
loader: 'postcss-loader',
88
options: {
99
sourceMap: _DEV_ ? true : false,
10-
plugins: [
11-
require('autoprefixer'),
12-
// require('postcss-pxtorem')({
13-
// rootValue: 40,
14-
// propList: ['*'],
15-
// selectorBlackList: [/^\.(vux|weui)-[\w]*/]
16-
// })
17-
]
10+
postcssOptions: {
11+
plugins: [
12+
['postcss-preset-env', {
13+
browsers: '> 0.5%, not dead, iOS >= 7, Android >= 4.3'
14+
}]
15+
]
16+
},
17+
// plugins: [
18+
// require('autoprefixer'),
19+
// // require('postcss-pxtorem')({
20+
// // rootValue: 40,
21+
// // propList: ['*'],
22+
// // selectorBlackList: [/^\.(vux|weui)-[\w]*/]
23+
// // })
24+
// ]
1825
}
1926
}
2027

build/webpack.base.conf.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require('path'),
44
CopyWebpackPlugin = require('copy-webpack-plugin'),
55
MiniCssExtractPlugin = require("mini-css-extract-plugin"),
66
ManifestPlugin = require('webpack-manifest-plugin'),
7-
SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
7+
{GenerateSW} = require('workbox-webpack-plugin');
88

99
const _PROD_ = process.env.NODE_ENV === 'production';
1010

@@ -155,7 +155,7 @@ module.exports = {
155155
maxAsyncRequests: 5,
156156
maxInitialRequests: 3,
157157
automaticNameDelimiter: '~',
158-
name: true,
158+
// name: true,
159159
cacheGroups: {
160160
react: {
161161
name: 'vendor',
@@ -187,36 +187,39 @@ module.exports = {
187187
// },
188188
// _DEV_: JSON.stringify(_DEV_),
189189
// }),
190-
new ManifestPlugin({
191-
fileName: 'asset-manifest.json'
192-
}),
193-
new SWPrecacheWebpackPlugin({
194-
dontCacheBustUrlsMatching: /\.\w{8}\./,
195-
filename: 'serviceWorker.js',
196-
logger(message) {
197-
console.log(message);
198-
if (message.indexOf('Total precache size is') === 0) {
199-
return;
200-
}
201-
if (message.indexOf('Skipping static resource') === 0) {
202-
return;
203-
}
204-
},
205-
minify: true,
206-
navigateFallback: '/index.html',
207-
navigateFallbackWhitelist: [/^(?!\/__).*/],
208-
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
209-
}),
190+
new GenerateSW(),
191+
// new ManifestPlugin({
192+
// fileName: 'asset-manifest.json'
193+
// }),
194+
// new SWPrecacheWebpackPlugin({
195+
// dontCacheBustUrlsMatching: /\.\w{8}\./,
196+
// filename: 'serviceWorker.js',
197+
// logger(message) {
198+
// console.log(message);
199+
// if (message.indexOf('Total precache size is') === 0) {
200+
// return;
201+
// }
202+
// if (message.indexOf('Skipping static resource') === 0) {
203+
// return;
204+
// }
205+
// },
206+
// minify: true,
207+
// navigateFallback: '/index.html',
208+
// navigateFallbackWhitelist: [/^(?!\/__).*/],
209+
// staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
210+
// }),
210211
new MiniCssExtractPlugin({
211212
filename: "static/css/[name].[contenthash].css",
212213
}),
213214
new webpack.ProvidePlugin({
214215
$http: [resolve('src/utils/http.ts'), 'default'],
215216
$msg: [resolve('node_modules/antd/es/message/index.js'), 'default']
216217
}),
217-
new CopyWebpackPlugin([{
218-
from: resolve('statics'),
219-
ignore: ['.*']
220-
}])
218+
new CopyWebpackPlugin({
219+
patterns: [{
220+
from: resolve('statics'),
221+
// ignore: ['.*']
222+
}]
223+
})
221224
]
222225
}

build/webpack.dev.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const path = require('path'),
22
webpack = require('webpack'),
3-
merge = require('webpack-merge'),
3+
{ merge } = require('webpack-merge'),
44
webpackConfig = require('./webpack.base.conf'),
55
HtmlWebpackPlugin = require('html-webpack-plugin');
66

77
module.exports = merge(webpackConfig, {
8-
devtool: 'cheap-modules-eval-source-map',
8+
devtool: 'eval',
99
mode: 'development',
1010
devServer: {
1111
port: '8060',

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,32 @@
4545
"@types/react-router-dom": "^4.3.1",
4646
"@typescript-eslint/eslint-plugin": "^2.4.0",
4747
"@typescript-eslint/parser": "^2.4.0",
48-
"autoprefixer": "^9.3.1",
4948
"babel-loader": "^8.0.4",
5049
"clean-webpack-plugin": "^0.1.19",
51-
"copy-webpack-plugin": "^4.6.0",
50+
"copy-webpack-plugin": "^7.0.0",
5251
"css-loader": "^1.0.1",
5352
"eslint": "^6.5.1",
5453
"eslint-plugin-react": "^7.16.0",
55-
"html-webpack-plugin": "^3.2.0",
54+
"html-webpack-plugin": "^4.5.0",
5655
"husky": "^3.0.9",
5756
"lint-staged": "^9.4.2",
58-
"mini-css-extract-plugin": "^0.4.4",
59-
"node-sass": "^4.12.0",
57+
"mini-css-extract-plugin": "^1.3.3",
58+
"node-sass": "^5.0.0",
6059
"optimize-css-assets-webpack-plugin": "^5.0.1",
61-
"postcss-loader": "^3.0.0",
62-
"react-hot-loader": "^4.3.12",
63-
"sass-loader": "^7.1.0",
60+
"postcss-loader": "^4.1.0",
61+
"postcss-preset-env": "^6.7.0",
62+
"sass-loader": "^10.1.0",
6463
"style-loader": "^0.23.1",
6564
"sw-precache-webpack-plugin": "^0.11.5",
6665
"typescript": "^3.6.4",
6766
"uglifyjs-webpack-plugin": "^2.0.1",
6867
"url-loader": "^1.1.2",
69-
"webpack": "^4.41.1",
70-
"webpack-cli": "^3.3.9",
71-
"webpack-dev-server": "^3.8.2",
68+
"webpack": "^5.10.3",
69+
"webpack-cli": "^3.3.12",
70+
"webpack-dev-server": "^3.11.0",
7271
"webpack-manifest-plugin": "^2.0.4",
73-
"webpack-merge": "^4.2.2"
72+
"webpack-merge": "^5.7.2",
73+
"workbox-webpack-plugin": "^6.0.2"
7474
},
7575
"husky": {
7676
"hooks": {

src/pages/dashboard/dashboard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default class Dashboard extends React.Component {
77
<div>GraphQL Application. </div>
88
<p style={{width: '400PX', height: 40, fontSize: '24px'}}>测试rem</p>
99
<div>66px</div>
10+
<div className="testcss">9999</div>
1011
</div>
1112
}
1213
}

0 commit comments

Comments
 (0)