Skip to content

Commit

Permalink
build: fix antd 在生产打包时 css 丢失问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sunss committed Aug 12, 2021
1 parent e46f042 commit 2621610
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
5 changes: 1 addition & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const { argv } = require('yargs');
const isDev = argv.mode === 'development';

module.exports = {
presets: [
[
Expand All @@ -27,7 +24,7 @@ module.exports = {
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
'react-hot-loader/babel',
isDev && [
[
'import',
{
libraryName: 'antd',
Expand Down
7 changes: 5 additions & 2 deletions config/webpack.base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const paths = require('./paths');
const { argv } = require('yargs');
const isDev = argv.mode === 'development';

/** @type {import('webpack').Configuration} */
module.exports = {
Expand All @@ -21,13 +24,13 @@ module.exports = {
// .css
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
use: [isDev ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader'],
},
// .less
{
test: /\.less$/,
use: [
'style-loader',
isDev ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'less-loader',
Expand Down
16 changes: 8 additions & 8 deletions config/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const prodConfig = {
chunkFilename: '[name].[chunkhash].chunk.js',
},

module: {
rules: [
{
test: /\.(css|less)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'less-loader'],
},
],
},
// module: {
// rules: [
// {
// test: /\.(css|less)$/,
// use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'less-loader'],
// },
// ],
// },

optimization: {
minimize: true,
Expand Down

0 comments on commit 2621610

Please sign in to comment.