Skip to content

Commit d3c8ac7

Browse files
committed
Replace sass option 'resolve_url_loader' by 'resolveUrlLoader'
1 parent 0d3a91b commit d3c8ac7

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ const publicApi = {
331331
* // options.includePaths = [...]
332332
* }, {
333333
* // set optional Encore-specific options
334-
* // resolve_url_loader: true
334+
* // resolveUrlLoader: true
335335
* });
336336
*
337337
* Supported options:
338-
* * {bool} resolve_url_loader (default=true)
338+
* * {bool} resolveUrlLoader (default=true)
339339
* Whether or not to use the resolve-url-loader.
340340
* Setting to false can increase performance in some
341341
* cases, especially when using bootstrap_sass. But,

lib/WebpackConfig.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class WebpackConfig {
4545
this.useSassLoader = false;
4646
this.sassLoaderOptionsCallback = function() {};
4747
this.sassOptions = {
48-
resolve_url_loader: true
48+
resolveUrlLoader: true
4949
};
5050
this.useLessLoader = false;
5151
this.lessLoaderOptionsCallback = function() {};
@@ -251,11 +251,17 @@ class WebpackConfig {
251251
this.sassLoaderOptionsCallback = sassLoaderOptionsCallback;
252252

253253
for (const optionKey of Object.keys(options)) {
254-
if (!(optionKey in this.sassOptions)) {
255-
throw new Error(`Invalid option "${optionKey}" passed to enableSassLoader(). Valid keys are ${Object.keys(this.sassOptions).join(', ')}`);
254+
let normalizedOptionKey = optionKey;
255+
if (optionKey === 'resolve_url_loader') {
256+
logger.warning('enableSassLoader: "resolve_url_loader" is deprecated. Please use "resolveUrlLoader" instead.');
257+
normalizedOptionKey = 'resolveUrlLoader';
256258
}
257259

258-
this.sassOptions[optionKey] = options[optionKey];
260+
if (!(normalizedOptionKey in this.sassOptions)) {
261+
throw new Error(`Invalid option "${normalizedOptionKey}" passed to enableSassLoader(). Valid keys are ${Object.keys(this.sassOptions).join(', ')}`);
262+
}
263+
264+
this.sassOptions[normalizedOptionKey] = options[optionKey];
259265
}
260266
}
261267

lib/loaders/sass.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

test/WebpackConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ describe('WebpackConfig object', () => {
346346

347347
it('Pass valid config', () => {
348348
const config = createConfig();
349-
config.enableSassLoader(() => {}, { resolve_url_loader: false });
349+
config.enableSassLoader(() => {}, { resolveUrlLoader: false });
350350

351351
expect(config.useSassLoader).to.be.true;
352-
expect(config.sassOptions.resolve_url_loader).to.be.false;
352+
expect(config.sassOptions.resolveUrlLoader).to.be.false;
353353
});
354354

355355
it('Pass invalid config', () => {

test/loaders/sass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)