Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit f17e6df

Browse files
committed
Allow to disable postCSS loader
1 parent 57edbf8 commit f17e6df

1 file changed

Lines changed: 33 additions & 27 deletions

File tree

packages/devtools-launchpad/webpack.config.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require("babel-register");
77
const path = require("path");
88

99
const webpack = require("webpack");
10-
const { NormalModuleReplacementPlugin } = require("webpack");
1110

1211
const ExtractTextPlugin = require("extract-text-webpack-plugin");
1312
const {
@@ -78,8 +77,9 @@ module.exports = (webpackConfig, envConfig, options = {}) => {
7877
* by the postcss-loader to /mc/devtools/client/themes/arrow.svg
7978
* and are hosted in `development-server` with an express server.
8079
*
81-
* CSS URLs like resource://devtools/client/themes/variables.css are mapped
82-
* by the NormalModuleReplacementPlugin to devtools-mc-assets/assets/devtools/client/themes/arrow.svg.
80+
* CSS URLs like resource://devtools/client/themes/variables.css are mapped by the
81+
* NormalModuleReplacementPlugin to
82+
* devtools-mc-assets/assets/devtools/client/themes/arrow.svg.
8383
* The modules are then resolved by the css-loader, which allows modules like
8484
* variables.css to be bundled.
8585
*
@@ -93,27 +93,29 @@ module.exports = (webpackConfig, envConfig, options = {}) => {
9393
loader: "svg-inline-loader"
9494
});
9595

96+
const cssUses = [{
97+
loader: "style-loader"
98+
}, {
99+
loader: "css-loader",
100+
options: {
101+
importLoaders: 1,
102+
url: false
103+
}
104+
}];
105+
106+
if (options.disablePostCSS !== true) {
107+
cssUses.push({ loader: "postcss-loader" });
108+
}
109+
96110
webpackConfig.module.rules.push({
97111
test: /\.css$/,
98-
use: [
99-
{ loader: "style-loader" },
100-
{
101-
loader: "css-loader",
102-
options: {
103-
importLoaders: 1,
104-
url: false
105-
}
106-
},
107-
{
108-
loader: "postcss-loader"
109-
}
110-
]
112+
use: cssUses
111113
});
112114

113115
webpackConfig.plugins.push(
114116
new webpack.NormalModuleReplacementPlugin(
115117
/(resource:|chrome:).*.css/,
116-
function(resource) {
118+
function (resource) {
117119
const newUrl = resource.request
118120
.replace(
119121
/(.\/chrome:\/\/|.\/resource:\/\/)/,
@@ -140,6 +142,19 @@ module.exports = (webpackConfig, envConfig, options = {}) => {
140142
* SVG URLS like chrome://devtools/skin/images/add.svg are
141143
* ignored as they are already available in MC.
142144
*/
145+
146+
const cssUses = [{
147+
loader: "css-loader",
148+
options: {
149+
importLoaders: 1,
150+
url: false
151+
}
152+
}];
153+
154+
if (options.disablePostCSS !== true) {
155+
cssUses.push({ loader: "postcss-loader" });
156+
}
157+
143158
// Extract CSS into a single file
144159
webpackConfig.module.rules.push({
145160
test: /\.css$/,
@@ -151,16 +166,7 @@ module.exports = (webpackConfig, envConfig, options = {}) => {
151166
},
152167
use: ExtractTextPlugin.extract({
153168
filename: "*.css",
154-
use: [
155-
{
156-
loader: "css-loader",
157-
options: {
158-
importLoaders: 1,
159-
url: false
160-
}
161-
},
162-
{ loader: "postcss-loader" }
163-
]
169+
use: cssUses
164170
})
165171
});
166172

0 commit comments

Comments
 (0)