File tree Expand file tree Collapse file tree 7 files changed +29
-14
lines changed Expand file tree Collapse file tree 7 files changed +29
-14
lines changed Original file line number Diff line number Diff line change @@ -429,11 +429,11 @@ const publicApi = {
429429 * // options.includePaths = [...]
430430 * }, {
431431 * // set optional Encore-specific options
432- * // resolve_url_loader : true
432+ * // resolveUrlLoader : true
433433 * });
434434 *
435435 * Supported options:
436- * * {bool} resolve_url_loader (default=true)
436+ * * {bool} resolveUrlLoader (default=true)
437437 * Whether or not to use the resolve-url-loader.
438438 * Setting to false can increase performance in some
439439 * cases, especially when using bootstrap_sass. But,
Original file line number Diff line number Diff line change @@ -57,16 +57,16 @@ class WebpackConfig {
5757 this . useSassLoader = false ;
5858 this . useReact = false ;
5959 this . usePreact = false ;
60- this . preactOptions = {
61- preactCompat : false
62- } ;
6360 this . useVueLoader = false ;
6461 this . useTypeScriptLoader = false ;
6562 this . useForkedTypeScriptTypeChecking = false ;
6663
6764 // Features/Loaders options
6865 this . sassOptions = {
69- resolve_url_loader : true
66+ resolveUrlLoader : true
67+ } ;
68+ this . preactOptions = {
69+ preactCompat : false
7070 } ;
7171
7272 // Features/Loaders options callbacks
@@ -311,11 +311,17 @@ class WebpackConfig {
311311 this . sassLoaderOptionsCallback = sassLoaderOptionsCallback ;
312312
313313 for ( const optionKey of Object . keys ( options ) ) {
314- if ( ! ( optionKey in this . sassOptions ) ) {
315- throw new Error ( `Invalid option "${ optionKey } " passed to enableSassLoader(). Valid keys are ${ Object . keys ( this . sassOptions ) . join ( ', ' ) } ` ) ;
314+ let normalizedOptionKey = optionKey ;
315+ if ( optionKey === 'resolve_url_loader' ) {
316+ logger . deprecation ( 'enableSassLoader: "resolve_url_loader" is deprecated. Please use "resolveUrlLoader" instead.' ) ;
317+ normalizedOptionKey = 'resolveUrlLoader' ;
318+ }
319+
320+ if ( ! ( normalizedOptionKey in this . sassOptions ) ) {
321+ throw new Error ( `Invalid option "${ normalizedOptionKey } " passed to enableSassLoader(). Valid keys are ${ Object . keys ( this . sassOptions ) . join ( ', ' ) } ` ) ;
316322 }
317323
318- this . sassOptions [ optionKey ] = options [ optionKey ] ;
324+ this . sassOptions [ normalizedOptionKey ] = options [ optionKey ] ;
319325 }
320326 }
321327
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ module.exports = {
2323 loaderFeatures . ensurePackagesExist ( 'sass' ) ;
2424
2525 const sassLoaders = [ ...cssLoader . getLoaders ( webpackConfig , ignorePostCssLoader ) ] ;
26- if ( true === webpackConfig . sassOptions . resolve_url_loader ) {
26+ if ( true === webpackConfig . sassOptions . resolveUrlLoader ) {
2727 // responsible for resolving SASS url() paths
2828 // without this, all url() paths must be relative to the
2929 // entry file, not the file that contains the url()
@@ -37,7 +37,7 @@ module.exports = {
3737
3838 let config = Object . assign ( { } , sassOptions , {
3939 // needed by the resolve-url-loader
40- sourceMap : ( true === webpackConfig . sassOptions . resolve_url_loader ) || webpackConfig . useSourceMaps
40+ sourceMap : ( true === webpackConfig . sassOptions . resolveUrlLoader ) || webpackConfig . useSourceMaps
4141 } ) ;
4242
4343 // allow options to be configured
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const messagesKeys = [
1515 'debug' ,
1616 'recommendation' ,
1717 'warning' ,
18+ 'deprecation' ,
1819] ;
1920const defaultConfig = {
2021 isVerbose : false ,
@@ -62,6 +63,12 @@ module.exports = {
6263 log ( `${ chalk . bgYellow . black ( ' WARNING ' ) } ${ chalk . yellow ( message ) } ` ) ;
6364 } ,
6465
66+ deprecation ( message ) {
67+ messages . deprecation . push ( message ) ;
68+
69+ log ( `${ chalk . bgYellow . black ( 'DEPRECATION' ) } ${ chalk . yellow ( message ) } ` ) ;
70+ } ,
71+
6572 getMessages ( ) {
6673 return messages ;
6774 } ,
Original file line number Diff line number Diff line change @@ -471,10 +471,10 @@ describe('WebpackConfig object', () => {
471471
472472 it ( 'Pass valid config' , ( ) => {
473473 const config = createConfig ( ) ;
474- config . enableSassLoader ( ( ) => { } , { resolve_url_loader : false } ) ;
474+ config . enableSassLoader ( ( ) => { } , { resolveUrlLoader : false } ) ;
475475
476476 expect ( config . useSassLoader ) . to . be . true ;
477- expect ( config . sassOptions . resolve_url_loader ) . to . be . false ;
477+ expect ( config . sassOptions . resolveUrlLoader ) . to . be . false ;
478478 } ) ;
479479
480480 it ( 'Pass invalid config' , ( ) => {
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ describe('loaders/sass', () => {
6767 it ( 'getLoaders() without resolve-url-loader' , ( ) => {
6868 const config = createConfig ( ) ;
6969 config . enableSassLoader ( ( ) => { } , {
70- resolve_url_loader : false ,
70+ resolveUrlLoader : false ,
7171 } ) ;
7272 config . enableSourceMaps ( false ) ;
7373
Original file line number Diff line number Diff line change @@ -28,12 +28,14 @@ describe('logger', () => {
2828 'debug' ,
2929 'recommendation' ,
3030 'warning' ,
31+ 'deprecation' ,
3132 ] ;
3233 const testString = 'TEST MESSAGE' ;
3334 const expectedMessages = {
3435 debug : [ testString ] ,
3536 recommendation : [ testString ] ,
3637 warning : [ testString ] ,
38+ deprecation : [ testString ] ,
3739 } ;
3840
3941 logger . quiet ( ) ;
You can’t perform that action at this time.
0 commit comments