Skip to content

Commit 7cf4ef4

Browse files
committed
fix
2 parents 2f57308 + 7727cc8 commit 7cf4ef4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5087
-5181
lines changed

.babelrc.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
module.exports = {
3+
presets: [
4+
[
5+
'@babel/preset-env',
6+
{
7+
targets: '> 0.25%, not dead',
8+
ignoreBrowserslistConfig: true,
9+
useBuiltIns: false,
10+
modules: false,
11+
exclude: ['transform-typeof-symbol']
12+
}
13+
],
14+
'@babel/preset-react',
15+
[
16+
'@babel/preset-typescript',
17+
{
18+
isTSX: true,
19+
allExtensions: true,
20+
allowNamespaces: true,
21+
allowDeclareFields: true
22+
}
23+
]
24+
],
25+
plugins: [
26+
[
27+
'@babel/plugin-proposal-decorators',
28+
{legacy: true}
29+
],
30+
[
31+
'@babel/plugin-proposal-class-properties',
32+
{loose: true}
33+
]
34+
]
35+
}

.browserslistrc

-2
This file was deleted.

.eslintrc.js

+30-14
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,46 @@ module.exports = {
2525
},
2626
'ecmaVersion': 2018,
2727
'sourceType': 'module',
28-
// 'project': './tsconfig.json'
28+
'project': './tsconfig.json'
2929
},
3030
'plugins': [
3131
'react',
32-
'@typescript-eslint',
33-
// 'prettier'
32+
'@typescript-eslint'
3433
],
3534
'rules': {
3635
'no-undef': 0,
37-
// 'indent': [ 'error', 2 ],
38-
'linebreak-style': [ 'error', 'unix' ],
39-
'quotes': [ 'error', 'single' ],
40-
'semi': [ 2, 'never' ],
41-
'no-unused-vars': 'off',
36+
'indent': 0,
37+
'linebreak-style': [ 2, 'unix' ],
38+
'quotes': 0,
39+
'semi': 0,
40+
'no-unused-vars': 0,
4241
'prefer-spread': 0,
4342
'prefer-const': 0,
4443
'switch-colon-spacing': [2, {'after': true, 'before': true}],
4544
'default-case': 2,
4645
'no-spaced-func': 2,
4746
'no-case-declarations': 0,
4847
'no-sparse-arrays': 0,
48+
'space-before-function-paren': 0,
49+
'keyword-spacing': 0,
50+
'key-spacing': 2,
51+
'comma-spacing': 0,
52+
'space-before-blocks': 2,
53+
'arrow-spacing': 2,
54+
'semi-spacing': 2,
55+
'no-irregular-whitespace': 2,
56+
4957
// react jsx
5058
'react/display-name': 0,
51-
'react/jsx-filename-extension': 'off',
52-
'react/jsx-first-prop-new-line': 'off',
53-
'react/jsx-indent': [ 'error', 2 ],
59+
'react/jsx-filename-extension': 0,
60+
'react/jsx-first-prop-new-line': 0,
61+
'react/jsx-indent': [ 2, 2 ],
5462
'react/jsx-indent-props': [2, 2],
5563
'react/prop-types': 0,
64+
'react/jsx-key': 2,
5665

57-
// @typescript-eslint
66+
// @typescript-eslint
67+
'@typescript-eslint/quotes': [2, 'single'],
5868
'@typescript-eslint/indent': [2, 2],
5969
'@typescript-eslint/camelcase': 0,
6070
'@typescript-eslint/explicit-function-return-type': 0,
@@ -67,9 +77,15 @@ module.exports = {
6777
'@typescript-eslint/no-angle-bracket-type-assertion': 0,
6878
'@typescript-eslint/interface-name-prefix': 0,
6979
'@typescript-eslint/no-empty-function': 1,
70-
'@typescript-eslint/semi': 0,
80+
'@typescript-eslint/semi': [2, 'never'],
7181
'@typescript-eslint/no-inferrable-types': 0,
7282
'@typescript-eslint/no-empty-interface': 0,
7383
'@typescript-eslint/class-name-casing': 0,
84+
'@typescript-eslint/explicit-module-boundary-types': 0,
85+
'@typescript-eslint/space-before-function-paren': [2],
86+
'@typescript-eslint/keyword-spacing': 0,
87+
'@typescript-eslint/comma-spacing': 2,
88+
'@typescript-eslint/type-annotation-spacing': 2,
89+
'@typescript-eslint/ban-types': 0
7490
}
75-
};
91+
}

.stylelintrc.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
module.exports = {
3+
'extends': 'stylelint-config-standard',
4+
'rules': {
5+
'selector-list-comma-newline-after': 'never-multi-line',
6+
'value-list-comma-newline-after': 'never-multi-line',
7+
'selector-pseudo-class-no-unknown': null,
8+
'declaration-colon-newline-after': null,
9+
'no-descending-specificity': null,
10+
'max-empty-lines': 2,
11+
'at-rule-no-unknown': [true, {
12+
ignoreAtRules: [/for|while|include/]
13+
}]
14+
},
15+
ignoreFiles: [
16+
'node_modules/**/*',
17+
'public/**/*',
18+
'dist/**/*',
19+
'**/*.js',
20+
'**/*.jsx',
21+
'**/*.tsx',
22+
'**/*.ts'
23+
]
24+
}

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### 项目概况
44
***
5-
使用蚂蚁金服的Antd开发的一套后台管理系统,主要用到了react、typescript、antd、mobx等技术,使用webpack4打包构建,包含React16的code splitting等新特性
5+
使用Ant-Design开发的一套后台管理系统,主要用到了React、Typescript、Mobx、PWA等技术,使用webpack5打包构建,包含React16的一些新特性
66

77
### 项目主要技术结构
88

@@ -13,6 +13,7 @@
1313
* mobx
1414
* webpack4
1515
* react-router4
16+
* pwa
1617

1718
### 安装
1819
***

build/styleLoaderConf.js

+15-8
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

+32-30
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const path = require('path'),
33
styleRules = require('./styleLoaderConf'),
44
CopyWebpackPlugin = require('copy-webpack-plugin'),
55
MiniCssExtractPlugin = require("mini-css-extract-plugin"),
6-
ManifestPlugin = require('webpack-manifest-plugin'),
7-
SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
6+
{GenerateSW} = require('workbox-webpack-plugin');
87

98
const DonePlugin = require('./donePlugin')
109
const _PROD_ = process.env.NODE_ENV === 'production';
@@ -24,7 +23,7 @@ module.exports = {
2423
publicPath: '/', // root Dir
2524
sourceMapFilename: '[name].map',
2625
chunkFilename: 'static/js/[name].[chunkhash:8].js',
27-
filename: 'static/js/[name].[hash:8].js'
26+
filename: 'static/js/[name].[contenthash:8].js'
2827
},
2928

3029
resolveLoader: {
@@ -84,15 +83,15 @@ module.exports = {
8483
test: /\.(eot|woff|woff2|ttf)(\?\S*)?$/,
8584
loader: "url-loader",
8685
options: {
87-
name: "assets/fonts/[name].[hash:8].[ext]",
86+
name: "assets/fonts/[name].[contenthash:8].[ext]",
8887
limit: 2048
8988
}
9089
},
9190
{
9291
test: /\.(svg|png|jpe?g|gif)(\?\S*)?$/,
9392
loader: "url-loader",
9493
options: {
95-
name: "assets/imgs/[name].[hash:8].[ext]",
94+
name: "assets/imgs/[name].[contenthash:8].[ext]",
9695
limit: 2048
9796
}
9897
}
@@ -156,7 +155,7 @@ module.exports = {
156155
maxAsyncRequests: 5,
157156
maxInitialRequests: 3,
158157
automaticNameDelimiter: '~',
159-
name: true,
158+
// name: true,
160159
cacheGroups: {
161160
react: {
162161
name: 'vendor',
@@ -190,36 +189,39 @@ module.exports = {
190189
// },
191190
// _DEV_: JSON.stringify(_DEV_),
192191
// }),
193-
new ManifestPlugin({
194-
fileName: 'asset-manifest.json'
195-
}),
196-
new SWPrecacheWebpackPlugin({
197-
dontCacheBustUrlsMatching: /\.\w{8}\./,
198-
filename: 'serviceWorker.js',
199-
logger(message) {
200-
console.log(message);
201-
if (message.indexOf('Total precache size is') === 0) {
202-
return;
203-
}
204-
if (message.indexOf('Skipping static resource') === 0) {
205-
return;
206-
}
207-
},
208-
minify: true,
209-
navigateFallback: '/index.html',
210-
navigateFallbackWhitelist: [/^(?!\/__).*/],
211-
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
212-
}),
192+
// new GenerateSW(),
193+
// new ManifestPlugin({
194+
// fileName: 'asset-manifest.json'
195+
// }),
196+
// new SWPrecacheWebpackPlugin({
197+
// dontCacheBustUrlsMatching: /\.\w{8}\./,
198+
// filename: 'serviceWorker.js',
199+
// logger(message) {
200+
// console.log(message);
201+
// if (message.indexOf('Total precache size is') === 0) {
202+
// return;
203+
// }
204+
// if (message.indexOf('Skipping static resource') === 0) {
205+
// return;
206+
// }
207+
// },
208+
// minify: true,
209+
// navigateFallback: '/index.html',
210+
// navigateFallbackWhitelist: [/^(?!\/__).*/],
211+
// staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
212+
// }),
213213
new MiniCssExtractPlugin({
214214
filename: "static/css/[name].[contenthash].css",
215215
}),
216216
new webpack.ProvidePlugin({
217217
$http: [resolve('src/utils/http.ts'), 'default'],
218218
$msg: [resolve('node_modules/antd/es/message/index.js'), 'default']
219219
}),
220-
new CopyWebpackPlugin([{
221-
from: resolve('statics'),
222-
ignore: ['.*']
223-
}])
220+
new CopyWebpackPlugin({
221+
patterns: [{
222+
from: resolve('statics'),
223+
// ignore: ['.*']
224+
}]
225+
})
224226
]
225227
}

build/webpack.dev.conf.js

+3-2
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',
@@ -26,6 +26,7 @@ module.exports = merge(webpackConfig, {
2626
// inline: true,
2727
https: false, // true for self-signed, object for cert authority
2828
// noInfo: true, // only errors & warns on hot reload
29+
progress: true,
2930
},
3031
plugins: [
3132
new webpack.HotModuleReplacementPlugin(),

build/webpack.prod.conf.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
'use strict'
2-
const path = require('path')
3-
const webpack = require('webpack')
4-
const merge = require('webpack-merge')
5-
const baseWebpackConfig = require('./webpack.base.conf')
6-
const HtmlWebpackPlugin = require('html-webpack-plugin')
7-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
8-
const CleanWebpackPlugin = require('clean-webpack-plugin')
9-
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin")
2+
const path = require('path'),
3+
webpack = require('webpack'),
4+
TerserPlugin = require("terser-webpack-plugin"),
5+
{merge} = require('webpack-merge'),
6+
baseWebpackConfig = require('./webpack.base.conf'),
7+
HtmlWebpackPlugin = require('html-webpack-plugin'),
8+
UglifyJsPlugin = require('uglifyjs-webpack-plugin'),
9+
OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
1010

1111
const _PROD_ = process.env.NODE_ENV === 'production'
1212

13-
const webpackConfig = merge(baseWebpackConfig, {
13+
module.exports = merge(baseWebpackConfig, {
1414
mode: 'production',
1515
devtool: false,
16+
optimization: {
17+
minimizer: [new TerserPlugin()]
18+
},
1619
plugins: [
1720
new CleanWebpackPlugin(['dist'], {root: path.resolve(__dirname, '../')}),
1821
new OptimizeCSSAssetsPlugin({
@@ -43,8 +46,6 @@ const webpackConfig = merge(baseWebpackConfig, {
4346
},
4447
}),
4548
// keep modules.id stable when vendor modules does not change
46-
new webpack.HashedModuleIdsPlugin(),
49+
// new webpack.HashedModuleIdsPlugin(),
4750
]
4851
})
49-
50-
module.exports = webpackConfig

0 commit comments

Comments
 (0)