From f8356ec7054148055c17ec8a00f81e72857f7685 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 5 Sep 2019 10:48:54 +0800 Subject: [PATCH] =?UTF-8?q?build:=20KERNEL-1221=20=E4=BC=98=E5=8C=96css?= =?UTF-8?q?=E6=89=93=E5=8C=85=EF=BC=8C=E5=8E=BB=E9=87=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/less/font.less | 4 ++-- webpack/webpack.dev.js | 15 ++++++++++++++- webpack/webpack.prod.js | 15 ++++++++++++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 3c1bd3b..764e348 100644 --- a/package.json +++ b/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", diff --git a/src/less/font.less b/src/less/font.less index 832beb8..b48119e 100644 --- a/src/less/font.less +++ b/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); diff --git a/webpack/webpack.dev.js b/webpack/webpack.dev.js index 2120e40..16cbbff 100644 --- a/webpack/webpack.dev.js +++ b/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 + }) ], }); diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index 4bb3786..0049917 100644 --- a/webpack/webpack.prod.js +++ b/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 }) ],