Skip to content

Commit 271f4cc

Browse files
committed
feat: support postcss loader options config and auto set sourceMap:true when devtool set
1 parent 0344d6f commit 271f4cc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/base.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ class WebpackBaseBuilder extends Config {
336336
if (Array.isArray(itemLoader.use)) {
337337
if (itemLoader.postcss) {
338338
const postcssIndex = ['css', 'css_module'].includes(name) ? itemLoader.use.length : itemLoader.use.length - 1;
339-
itemLoader.use.splice(postcssIndex, 0, 'postcss-loader');
339+
const postcssLoader = this.createPostCssLoader(loaderOptions && loaderOptions.postcss);
340+
itemLoader.use.splice(postcssIndex, 0, postcssLoader);
340341
}
341342
itemLoader.use.forEach((loader, index) => {
342343
const label = this.utils.getLoaderLabel(loader);
@@ -577,6 +578,11 @@ class WebpackBaseBuilder extends Config {
577578
this.styleLoader = { loader, options };
578579
}
579580

581+
createPostCssLoader(loaderOptions) {
582+
const options = this.merge(this.config.devtool ? { sourceMap: true } : {}, loaderOptions);
583+
return { loader: 'postcss-loader', options };
584+
}
585+
580586
createDllPlugin(dll) {
581587
dll = dll || this.config.dll;
582588
const dllArray = WebpackBaseBuilder.getDllConfig(dll);

0 commit comments

Comments
 (0)