Skip to content

Commit fd7c7b4

Browse files
committed
🛠 adds getDev and getProd functions to customizers, fixes Sass in build mode
1 parent 2c0d985 commit fd7c7b4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

‎packages/react-scripts/config/customizers.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
2+
13
module.exports = {
24
'BABEL_STAGE_0': {
35
toArray: 'presets',
4-
get: function () {
6+
getDev: function () {
57
return require.resolve('babel-preset-stage-0')
68
}
79
},
810
'DECORATORS': {
911
toArray: 'babelPlugins',
10-
get: function () {
12+
getDev: function () {
1113
return require.resolve('babel-plugin-transform-decorators-legacy')
1214
}
1315
},
1416
'SASS': {
1517
toArray: 'loaders',
16-
get: function () {
18+
getDev: function () {
1719
return {
1820
test: /\.scss$/,
1921
loader: "style!css!postcss!sass"
2022
}
23+
},
24+
getProd: function () {
25+
return {
26+
test: /\.scss$/,
27+
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')
28+
}
2129
}
2230
},
2331
'LESS': {
2432
toArray: 'loaders',
25-
get: function () {
33+
getDev: function () {
2634
return {
2735
test: /\.less$/,
2836
loader: "style!css!postcss!less"

‎packages/react-scripts/config/get-custom-config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ function getCustomConfig(prod) {
1414
var envValue = process.env['REACT_APP_' + customizerKey];
1515
if (env && envValue && envValue !== 'false') {
1616
if (customizer.toArray) {
17-
finalConfig[customizer.toArray].push(customizer.get());
17+
var getCustomizer = (prod ? customizer.getProd : customizer.getDev) || customizer.getDev;
18+
finalConfig[customizer.toArray].push(getCustomizer());
1819
}
1920
finalConfig.values[customizerKey] = customizer.config || true;
2021
}

0 commit comments

Comments
 (0)