Browse Source

build: KERNEL-1221 优化css打包,去重。

qufenxi
alan 5 years ago
parent
commit
f8356ec705
  1. 1
      package.json
  2. 4
      src/less/font.less
  3. 15
      webpack/webpack.dev.js
  4. 15
      webpack/webpack.prod.js

1
package.json

@ -45,6 +45,7 @@
"less-loader": "5.0.0",
"mini-css-extract-plugin": "0.7.0",
"npm-run-all": "4.1.5",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss-loader": "3.0.0",
"postcss-simple-vars": "5.0.2",
"properties-reader": "0.0.16",

4
src/less/font.less

@ -1,6 +1,6 @@
@import "../../node_modules/fineui/src/less/resource/font.less";
@import "../../node_modules/fineui/src/less/image.less";
@import "./lib/font.less";
.addFontRes();
.font(dcm-link-font, @font-link);
.font(dcm-info-font, @font-link-info);
.font(dcm-test-font, @font-link-test);

15
webpack/webpack.dev.js

@ -3,7 +3,7 @@ const merge = require('webpack-merge');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const chokidar = require('chokidar');
const { execSync } = require('child_process');
@ -65,5 +65,18 @@ module.exports = merge(common, {
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '../index.html'),
}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', {
discardComments: {
removeAll: true,
},
normalizeUnicode: false
}]
},
canPrint: true
})
],
});

15
webpack/webpack.prod.js

@ -2,7 +2,7 @@ const webpack = require('webpack');
const merge = require('webpack-merge');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const vars = require('postcss-simple-vars');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const dirs = require('./dirs');
const common = require('./webpack.common.js');
@ -25,6 +25,19 @@ module.exports = merge.smart(common, {
}),
new webpack.BannerPlugin({
banner: `time: ${new Date().toLocaleString()}`
}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', {
discardComments: {
removeAll: true,
},
normalizeUnicode: false
}]
},
canPrint: true
})
],

Loading…
Cancel
Save