File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -965,6 +965,27 @@ class Encore {
965
965
return this ;
966
966
}
967
967
968
+ /**
969
+ * Configure the css-loader.
970
+ *
971
+ * https://github.com/webpack-contrib/style-loader#Options
972
+ *
973
+ * ```
974
+ * Encore.configureStyleLoader(function(config) {
975
+ * // change the config
976
+ * // config.injectType: 'styleTag'
977
+ * });
978
+ * ```
979
+ *
980
+ * @param {function } callback
981
+ * @returns {Encore }
982
+ */
983
+ configureStyleLoader ( callback ) {
984
+ webpackConfig . configureStyleLoader ( callback ) ;
985
+
986
+ return this ;
987
+ }
988
+
968
989
/**
969
990
* If enabled, the react preset is added to Babel.
970
991
*
Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ class WebpackConfig {
142
142
this . babelConfigurationCallback = ( ) => { } ;
143
143
this . babelPresetEnvOptionsCallback = ( ) => { } ;
144
144
this . cssLoaderConfigurationCallback = ( ) => { } ;
145
+ this . styleLoaderConfigurationCallback = ( ) => { } ;
145
146
this . splitChunksConfigurationCallback = ( ) => { } ;
146
147
this . watchOptionsConfigurationCallback = ( ) => { } ;
147
148
this . devServerOptionsConfigurationCallback = ( ) => { } ;
@@ -468,6 +469,14 @@ class WebpackConfig {
468
469
this . cssLoaderConfigurationCallback = callback ;
469
470
}
470
471
472
+ configureStyleLoader ( callback ) {
473
+ if ( typeof callback !== 'function' ) {
474
+ throw new Error ( 'Argument 1 to configureStyleLoader() must be a callback function.' ) ;
475
+ }
476
+
477
+ this . styleLoaderConfigurationCallback = callback ;
478
+ }
479
+
471
480
enableSingleRuntimeChunk ( ) {
472
481
this . shouldUseSingleRuntimeChunk = true ;
473
482
}
Original file line number Diff line number Diff line change 11
11
12
12
const WebpackConfig = require ( '../WebpackConfig' ) ; //eslint-disable-line no-unused-vars
13
13
const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
14
+ const applyOptionsCallback = require ( '../utils/apply-options-callback' ) ;
14
15
15
16
module . exports = {
16
17
/**
@@ -22,13 +23,15 @@ module.exports = {
22
23
*/
23
24
prependLoaders ( webpackConfig , loaders ) {
24
25
if ( ! webpackConfig . extractCss ) {
26
+
27
+ const options = { } ;
28
+
25
29
// If the CSS extraction is disabled, use the
26
30
// style-loader instead.
27
31
return [ {
28
32
loader : 'style-loader' ,
29
- options : {
30
- sourceMap : webpackConfig . useSourceMaps ,
31
- }
33
+ options : applyOptionsCallback ( webpackConfig . styleLoaderConfigurationCallback , options )
34
+
32
35
} , ...loaders ] ;
33
36
}
34
37
You can’t perform that action at this time.
0 commit comments