mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
feat: add uglifyjs webpack plugin
This commit is contained in:
parent
ca623d7d38
commit
0365403a75
4 changed files with 37 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
const Config = require('webpack-chain');
|
||||
const CSSExtractPlugin = require('mini-css-extract-plugin');
|
||||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||
const path = require('path');
|
||||
|
||||
const mdLoader = require.resolve('./loader/markdown');
|
||||
|
@ -74,7 +75,7 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
mdRule
|
||||
.use('markdown-loader')
|
||||
.loader(mdLoader)
|
||||
.options({siteConfig});
|
||||
.options({siteConfig, siteDir, docsDir});
|
||||
|
||||
const cssRule = config.module.rule('css').test(/\.css$/);
|
||||
if (isProd) {
|
||||
|
@ -101,5 +102,20 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
}
|
||||
]);
|
||||
|
||||
if (isProd) {
|
||||
config.optimization.minimizer([
|
||||
new UglifyJsPlugin({
|
||||
cache: true,
|
||||
uglifyOptions: {
|
||||
warnings: false,
|
||||
compress: false,
|
||||
ecma: 6,
|
||||
mangle: true,
|
||||
},
|
||||
sourceMap: true
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue