Skip to content

Commit

Permalink
perf: entrypoint from 261kb to 219kb
Browse files Browse the repository at this point in the history
  • Loading branch information
joriewong committed Mar 24, 2021
1 parent 24a6fb0 commit fc107b3
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions build/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const path = require('path')
const webpack = require('webpack')
const { srcPath } = require('./myPath')

const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')

module.exports = {
entry: {
wangEditor: path.join(srcPath, 'wangEditor.ts'),
Expand All @@ -19,12 +23,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)(\?.*)?$/,
Expand Down Expand Up @@ -52,5 +52,18 @@ module.exports = {
ENV: JSON.stringify('dev1'),
ENV1: JSON.stringify(process.env.NODE_ENV),
}),
new MiniCssExtractPlugin({
filename: 'css/main.css',
}),
],
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin(),
],
},
}

0 comments on commit fc107b3

Please sign in to comment.