Skip to content

Commit

Permalink
fix bug miniCSSExtract
Browse files Browse the repository at this point in the history
  • Loading branch information
partyk committed May 26, 2020
1 parent b5028b6 commit a870597
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 44 deletions.
14 changes: 1 addition & 13 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ module.exports = merge(
{
mode: 'development',
// a complete list of "stats" setting is on https://webpack.js.org/configuration/stats/
stats: {
// copied from `'minimal'`
all: false,
assets: false,
modules: true,
maxModules: 0,
errors: false, // disabled errors
warnings: false, // disabled warnings
// our additional options
moduleTrace: true,
errorDetails: true
},
resolve: {
extensions: ['.vue', '.css', '.tsx', '.ts', '.js', '.json'],
modules: [
Expand All @@ -36,8 +24,8 @@ module.exports = merge(
},
plugins: [
plugins.clean(),
plugins.friendlyErrors(),
plugins.copy(),
plugins.miniCssExtract(),
plugins.imageMin(),
plugins.iconFont(),
plugins.webpackBar(),
Expand Down
13 changes: 13 additions & 0 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ const plugins = require('./webpack/plugins/index');

module.exports = merge(common, {
mode: 'development',
stats: {
// copied from `'minimal'`
all: false,
assets: false,
modules: true,
maxModules: 0,
errors: false, // disabled errors
warnings: false, // disabled warnings
// our additional options
moduleTrace: true,
errorDetails: true
},
devtool: 'source-map',
devServer: {
contentBase: './dist'
Expand All @@ -22,6 +34,7 @@ module.exports = merge(common, {
ignored: /node_modules/
},
plugins: [
plugins.friendlyErrors(),
plugins.bundleAnalyzer() //,
// plugins.dashboard()
// plugins.browserSync()
Expand Down
9 changes: 1 addition & 8 deletions webpack/loaders/webpack.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,5 @@ module.exports = ({include, exclude} = {}) => ({
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: '[id].[hash].css',
ignoreOrder: false // Enable to remove warnings about conflicting order
})
]
}
});
21 changes: 8 additions & 13 deletions webpack/loaders/webpack.less.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const path = require('path');
const modules = require('./../modules/index');

/* plugins */
// const plugins = require('./../webpack.plugins');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = ({include, exclude} = {}) => ({
Expand All @@ -32,11 +31,14 @@ module.exports = ({include, exclude} = {}) => ({
importLoaders: 4,
sourceMap: config.isDevelop
}
}, /*
{
loader: 'resolve-url-loader'
},*/
},
modules.loaderPostCSS(),
/* {
loader: 'resolve-url-loader',
options: {
removeCR: true
},
}, */
// modules.loaderIconFont(),
{
loader: 'less-loader',
Expand All @@ -51,12 +53,5 @@ module.exports = ({include, exclude} = {}) => ({
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/chunks/[id].[hash].css',
ignoreOrder: false // Enable to remove warnings about conflicting order
})
]
}
});
14 changes: 5 additions & 9 deletions webpack/loaders/webpack.scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ module.exports = ({include, exclude} = {}) => ({
}
},
{
loader: 'resolve-url-loader'
loader: 'resolve-url-loader',
options: {
removeCR: true
}
},
modules.loaderPostCSS(),
modules.loaderIconFont(),
Expand All @@ -51,12 +54,5 @@ module.exports = ({include, exclude} = {}) => ({
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: '[id].[hash].css',
ignoreOrder: false // Enable to remove warnings about conflicting order
})
]
}
});
3 changes: 2 additions & 1 deletion webpack/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ exports.clean = require('./webpack.clean');
exports.terser = require('./webpack.terser');
exports.duplicatePackageChecker = require('./webpack.duplicatePackageChecker');
exports.bundleAnalyzer = require('./webpack.bundleAnalyzer');
exports.vueLoader = require('./webpack.vueLoader');
exports.vueLoader = require('./webpack.vueLoader');
exports.miniCssExtract = require('./webpack.miniCssExtract');
10 changes: 10 additions & 0 deletions webpack/plugins/webpack.miniCssExtract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = (options = {}) => {
return new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/chunks/[id].[hash].css',
ignoreOrder: false, // Enable to remove warnings about conflicting order,
...options
});
};

0 comments on commit a870597

Please sign in to comment.