build: update packages

This commit is contained in:
Tristan 2020-09-06 22:08:57 +08:00
parent 3100df14eb
commit 356cae3ecb
7 changed files with 8237 additions and 9924 deletions

View File

@ -1,7 +1,6 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const InterpolateHtmlPlugin = require('interpolate-html-plugin');
const paths = require('./paths');
const getClientEnvironment = require('./env');
const HappyPack = require('happypack');
@ -17,7 +16,7 @@ const env = getClientEnvironment(publicUrl);
module.exports = {
resolve: {
// webpack 能识别的文件扩展名
extensions: ['.js', '.jsx', '.json', '.less', '.css']
extensions: ['.js', '.jsx', '.json', '.less', '.css'],
// 针对 npm 中的第三方模块优先采用 jsnext:main 中指向的 ES6 模块化语法的文件
// mainFields: ["jsnext:main", "browser", "main"]
},
@ -30,15 +29,15 @@ module.exports = {
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000
}
limit: 10000,
},
},
// babel loader
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
exclude: /node_modules/,
use: 'happypack/loader'
use: 'happypack/loader',
},
// file-loader将所有静态文件可被WebpackDevServer伺服
// 生产环境这些静态文件会被拷贝到build目录
@ -50,16 +49,16 @@ module.exports = {
/\.(bmp|gif|jpe?g|png)$/,
/\.less$/,
/\.html$/,
/\.json$/
/\.json$/,
],
loader: 'file-loader',
options: {
name: 'static/assets/[name].[hash:8].[ext]'
}
}
]
}
]
name: 'static/assets/[name].[hash:8].[ext]',
},
},
],
},
],
},
plugins: [
new HappyPack({
@ -67,10 +66,10 @@ module.exports = {
{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
]
cacheDirectory: true,
},
},
],
}),
new HtmlWebpackPlugin({
inject: true,
@ -88,8 +87,8 @@ module.exports = {
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
minifyURLs: true,
},
}),
new AutoDllPlugin(
process.env.NODE_ENV === 'development'
@ -101,11 +100,10 @@ module.exports = {
filename: '[name]_[hash].dll.js',
path: './dll',
entry: {
react: ['react', 'react-dom', 'styled-components']
}
react: ['react', 'react-dom', 'styled-components'],
},
}
),
new InterpolateHtmlPlugin(env.raw)
],
// node中用到但是浏览器不用到的类库给出空对象模拟
node: {
@ -113,6 +111,6 @@ module.exports = {
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
child_process: 'empty',
},
};

View File

@ -1,7 +1,7 @@
const webpack = require('webpack');
const paths = require('./paths');
const merge = require('webpack-merge');
const { merge } = require('webpack-merge');
const commonConfig = require('./webpack.config.common');
// 为方便配置,以根目录为本地服务器地址
const publicPath = '/';
@ -15,7 +15,7 @@ module.exports = merge(commonConfig, {
// 热更新,并实时显示错误
'react-dev-utils/webpackHotDevClient',
// 主要代码,之所以放在最后,是为了程序有错误,修改后还能刷新
paths.appIndexJs
paths.appIndexJs,
],
output: {
// Add /* filename */ comments to generated require()s in the output.
@ -26,7 +26,7 @@ module.exports = merge(commonConfig, {
// chunk 文件(开启 code splitting 才会有)
chunkFilename: 'static/js/[name].chunk.js',
// WebpackDevServer 伺服的根目录:/
publicPath
publicPath,
},
module: {
@ -45,35 +45,35 @@ module.exports = merge(commonConfig, {
{
loader: 'css-loader',
options: {
importLoaders: 1
}
}
]
}
]
}
]
importLoaders: 1,
},
},
],
},
],
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development')
}
NODE_ENV: JSON.stringify('development'),
},
}),
// Add module names to factory functions so they appear in browser profiler.
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
new webpack.HotModuleReplacementPlugin(),
],
// Turn off performance hints during development because we don't do any
// splitting or minification in interest of speed. These warnings become
// cumbersome.
performance: {
hints: false
hints: false,
},
optimization: {
splitChunks: {
chunks: 'all'
}
}
chunks: 'all',
},
},
});

View File

@ -1,7 +1,7 @@
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const merge = require('webpack-merge');
const { merge } = require('webpack-merge');
const commonConfig = require('./webpack.config.common');
const paths = require('./paths');
const TerserPlugin = require('terser-webpack-plugin');
@ -20,10 +20,10 @@ module.exports = merge(commonConfig, {
// 主文件以及一个异步加载chunk的文件
filename: 'static/js/[name].[chunkhash:6].js',
chunkFilename: 'static/js/[name].[chunkhash:6].chunk.js',
publicPath: paths.servedPath
publicPath: paths.servedPath,
},
resolve: {
modules: [__dirname, 'node_modules']
modules: [__dirname, 'node_modules'],
},
module: {
rules: [
@ -31,30 +31,30 @@ module.exports = merge(commonConfig, {
oneOf: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
}
]
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'production')
}
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'production'),
},
}),
new webpack.NamedChunksPlugin(),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: '[name].css',
chunkFilename: '[name].css'
chunkFilename: '[name].css',
}),
// Generate a manifest file which contains a mapping of all asset filenames
// to their corresponding output file so that tools can pick it up without
// having to parse `index.html`.
new ManifestPlugin({
fileName: 'asset-manifest.json'
fileName: 'asset-manifest.json',
}),
new GenerateSW({
clientsClaim: true,
@ -73,14 +73,14 @@ module.exports = merge(commonConfig, {
//配置 expiration
expiration: {
maxEntries: 10,
maxAgeSeconds: 60
maxAgeSeconds: 60,
},
//配置哪些响应被认为是可缓存的
cacheableResponse: {
statuses: [0, 200]
}
}
statuses: [0, 200],
},
},
},
{
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
@ -93,14 +93,14 @@ module.exports = merge(commonConfig, {
//配置 expiration
expiration: {
maxEntries: 10,
maxAgeSeconds: 3600
maxAgeSeconds: 3600,
},
//配置哪些响应被认为是可缓存的
cacheableResponse: {
statuses: [0, 200]
}
}
statuses: [0, 200],
},
},
},
{
urlPattern: /\.js$/,
@ -113,15 +113,15 @@ module.exports = merge(commonConfig, {
//配置 expiration
expiration: {
maxEntries: 10,
maxAgeSeconds: 3600
maxAgeSeconds: 3600,
},
//配置哪些响应被认为是可缓存的
cacheableResponse: {
statuses: [0, 200]
}
}
}
statuses: [0, 200],
},
},
},
],
navigateFallbackDenylist: [
// Exclude URLs starting with /_, as they're likely an API call
@ -130,13 +130,13 @@ module.exports = merge(commonConfig, {
// as they're likely a resource and not a SPA route.
// URLs containing a "?" character won't be blacklisted as they're likely
// a route with query params (e.g. auth callbacks).
new RegExp('/[^/?]+\\.[^/]+$')
]
new RegExp('/[^/?]+\\.[^/]+$'),
],
}),
new BundleAnalyzerPlugin({
openAnalyzer: false,
analyzerMode: 'static'
})
analyzerMode: 'static',
}),
],
optimization: {
minimizer: [
@ -145,10 +145,10 @@ module.exports = merge(commonConfig, {
mangle: true,
ecma: 8,
compress: {
drop_console: true
}
}
})
]
}
drop_console: true,
},
},
}),
],
},
});

View File

@ -6,7 +6,7 @@ const paths = require('./paths');
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const host = process.env.HOST || '0.0.0.0';
module.exports = function(proxy, allowedHost) {
module.exports = function (proxy, allowedHost) {
return {
// gzip
compress: true,
@ -48,7 +48,7 @@ module.exports = function(proxy, allowedHost) {
// src/node_modules is not ignored to support absolute imports
// https://github.com/facebookincubator/create-react-app/issues/1065
watchOptions: {
ignored: ignoredFiles(paths.appSrc)
ignored: ignoredFiles(paths.appSrc),
},
// Enable HTTPS if the HTTPS environment variable is set to 'true'
https: protocol === 'https',
@ -57,7 +57,7 @@ module.exports = function(proxy, allowedHost) {
historyApiFallback: {
// Paths with dots should still use the history fallback.
// See https://github.com/facebookincubator/create-react-app/issues/387.
disableDotRule: true
disableDotRule: true,
},
public: allowedHost,
proxy,
@ -69,7 +69,7 @@ module.exports = function(proxy, allowedHost) {
// We do this in development to avoid hitting the production cache if
// it used the same host and port.
// https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
app.use(noopServiceWorkerMiddleware());
}
app.use(noopServiceWorkerMiddleware('/'));
},
};
};

11758
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -29,64 +29,61 @@
},
"homepage": "https://ichuantong.cn",
"dependencies": {
"@ungap/url-search-params": "^0.1.4",
"@welldone-software/why-did-you-render": "^4.0.5",
"@ungap/url-search-params": "^0.2.2",
"color-convert": "^2.0.1",
"file-saver": "^2.0.2",
"html2canvas": "^1.0.0-rc.5",
"html2canvas": "^1.0.0-rc.7",
"jinrishici": "^1.0.6",
"pinyin": "^2.9.0",
"react": "^16.13.0",
"pinyin": "^2.9.1",
"react": "^16.13.1",
"react-copy-to-clipboard": "^5.0.2",
"react-dom": "^16.13.0",
"react-github-btn": "^1.1.1",
"react-router-dom": "^5.1.2",
"smooth-scroll-into-view-if-needed": "^1.1.27",
"styled-components": "^5.0.1",
"styled-reset": "^4.1.1"
"react-dom": "^16.13.1",
"react-github-btn": "^1.2.0",
"react-router-dom": "^5.2.0",
"smooth-scroll-into-view-if-needed": "^1.1.29",
"styled-components": "^5.2.0",
"styled-reset": "^4.2.2"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.8.7",
"@babel/preset-react": "^7.8.3",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"auto-changelog": "^1.16.2",
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.10.4",
"@commitlint/cli": "^9.1.2",
"@commitlint/config-conventional": "^9.1.2",
"auto-changelog": "^2.2.0",
"autodll-webpack-plugin": "^0.4.2",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.0.6",
"css-loader": "^3.4.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^2.5.0",
"file-loader": "^5.1.0",
"gh-pages": "^2.2.0",
"babel-loader": "^8.1.0",
"css-loader": "^4.2.2",
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"file-loader": "^6.1.0",
"happypack": "^5.0.1",
"html-webpack-plugin": "^3.2.0",
"husky": "^4.2.3",
"html-webpack-plugin": "^4.4.1",
"husky": "^4.2.5",
"installed-check-core": "^3.0.0",
"interpolate-html-plugin": "^3.0.0",
"lint-staged": "^10.0.8",
"mini-css-extract-plugin": "^0.9.0",
"prettier": "^1.19.1",
"react-dev-utils": "^10.1.0",
"style-loader": "^1.1.3",
"terser-webpack-plugin": "^2.3.5",
"url-loader": "^3.0.0",
"webpack": "^4.42.0",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"lint-staged": "^10.3.0",
"mini-css-extract-plugin": "^0.11.0",
"prettier": "^2.1.1",
"react-dev-utils": "^10.2.1",
"style-loader": "^1.2.1",
"terser-webpack-plugin": "^4.1.0",
"url-loader": "^4.1.0",
"webpack": "^4.44.1",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-manifest-plugin": "^2.2.0",
"webpack-merge": "^4.2.2",
"workbox-webpack-plugin": "^5.0.0"
"webpack-merge": "^5.1.3",
"workbox-webpack-plugin": "^5.1.3"
},
"engines": {
"node": ">=10.0.0",
"node": ">=12.0.0",
"npm": ">=6.0.0"
}
}

6158
yarn.lock

File diff suppressed because it is too large Load Diff