release: v4.6.11 feature third contribution (#3091)

* perf: entrypoint from 261kb to 219kb
This commit is contained in:
echoLC 2021-03-25 21:03:18 +08:00 committed by GitHub
parent 702dcd53e7
commit ae477f2472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 15 deletions

View File

@ -7,6 +7,8 @@ const path = require('path')
const webpack = require('webpack')
const { srcPath } = require('./myPath')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
entry: {
wangEditor: path.join(srcPath, 'wangEditor.ts'),
@ -19,12 +21,8 @@ module.exports = {
include: /src/,
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.less$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'],
test: /\.(less|css)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'less-loader'],
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
@ -52,5 +50,8 @@ module.exports = {
ENV: JSON.stringify('dev1'),
ENV1: JSON.stringify(process.env.NODE_ENV),
}),
new MiniCssExtractPlugin({
filename: 'css/main.css',
}),
],
}

View File

@ -9,6 +9,8 @@ const CommonConf = require('./webpack.common')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const { distPath } = require('./myPath')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
// 包体积分析
const isAnalyzer = process.env.NODE_ENV === 'production_analyzer'
@ -29,4 +31,14 @@ module.exports = smart(CommonConf, {
},
plugins,
devtool: 'source-map',
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin(),
],
},
})

View File

@ -88,9 +88,11 @@
"less": "^3.11.1",
"less-loader": "^6.0.0",
"lint-staged": "^10.2.2",
"mini-css-extract-plugin": "^1.3.9",
"multiparty": "^4.2.2",
"nodemon": "^2.0.6",
"nyc": "^15.1.0",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"postcss-loader": "^3.0.0",
"prepend-file": "^2.0.0",
"prettier": "^2.0.5",
@ -99,6 +101,7 @@
"ts-jest": "^25.4.0",
"ts-loader": "^7.0.2",
"typescript": "^4.0.3",
"uglifyjs-webpack-plugin": "^2.2.0",
"url-loader": "^4.1.0",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.9.0",
@ -107,7 +110,8 @@
},
"dependencies": {
"@babel/runtime": "^7.11.2",
"@babel/runtime-corejs3": "^7.11.2"
"@babel/runtime-corejs3": "^7.11.2",
"tslib": "^2.1.0"
},
"husky": {
"hooks": {

View File

@ -23,10 +23,9 @@
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
"importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true,
/* Enable all strict type-checking options. */
@ -38,13 +37,11 @@
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
@ -57,17 +54,14 @@
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"forceConsistentCasingInFileNames": true,
/* Disallow inconsistently-cased references to the same file. */
@ -83,4 +77,4 @@
"lib",
"server"
]
}
}