8000 Replace "resolve_url_loader" by "resolveUrlLoader" by Lyrkan · Pull Request #159 · symfony/webpack-encore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replace "resolve_url_loader" by "resolveUrlLoader" #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ const publicApi = {
* // options.includePaths = [...]
* }, {
* // set optional Encore-specific options
* // resolve_url_loader: true
* // resolveUrlLoader: true
* });
*
* Supported options:
* * {bool} resolve_url_loader (default=true)
* * {bool} resolveUrlLoader (default=true)
* Whether or not to use the resolve-url-loader.
* Setting to false can increase performance in some
* cases, especially when using bootstrap_sass. But,
Expand Down
20 changes: 13 additions & 7 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ class WebpackConfig {
this.useSassLoader = false;
this.useReact = false;
this.usePreact = false;
this.preactOptions = {
preactCompat: false
};
this.useVueLoader = false;
this.useTypeScriptLoader = false;
this.useForkedTypeScriptTypeChecking = false;

// Features/Loaders options
this.sassOptions = {
resolve_url_loader: true
resolveUrlLoader: true
};
this.preactOptions = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR but it wasn't at the right place since #152 was merged after #144

preactCompat: false
};

// Features/Loaders options callbacks
Expand Down Expand Up @@ -311,11 +311,17 @@ class WebpackConfig {
this.sassLoaderOptionsCallback = sassLoaderOptionsCallback;

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

if (!(normalizedOptionKey in this.sassOptions)) {
throw new Error(`Invalid option "${normalizedOptionKey}" passed to enableSassLoader(). Valid keys are ${Object.keys(this.sassOptions).join(', ')}`);
}

this.sassOptions[optionKey] = options[optionKey];
this.sassOptions[normalizedOptionKey] = options[optionKey];
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/loaders/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
loaderFeatures.ensurePackagesExist('sass');

const sassLoaders = [...cssLoader.getLoaders(webpackConfig, ignorePostCssLoader)];
if (true === webpackConfig.sassOptions.resolve_url_loader) {
if (true === webpackConfig.sassOptions.resolveUrlLoader) {
// responsible for resolving SASS url() paths
// without this, all url() paths must be relative to the
// entry file, not the file that contains the url()
Expand All @@ -37,7 +37,7 @@ module.exports = {

let config = Object.assign({}, sassOptions, {
// needed by the resolve-url-loader
sourceMap: (true === webpackConfig.sassOptions.resolve_url_loader) || webpackConfig.useSourceMaps
sourceMap: (true === webpackConfig.sassOptions.resolveUrlLoader) || webpackConfig.useSourceMaps
});

// allow options to be configured
Expand Down
7 changes: 7 additions & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const messagesKeys = [
'debug',
'recommendation',
'warning',
'deprecation',
];
const defaultConfig = {
isVerbose: false,
Expand Down Expand Up @@ -62,6 +63,12 @@ module.exports = {
log(`${chalk.bgYellow.black(' WARNING ')} ${chalk.yellow(message)}`);
},

deprecation(message) {
messages.deprecation.push(message);

log(`${chalk.bgYellow.black('DEPRECATION')} ${chalk.yellow(message)}`);
},

getMessages() {
return messages;
},
Expand Down
4 changes: 2 additions & 2 deletions test/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ describe('WebpackConfig object', () => {

it('Pass valid config', () => {
const config = createConfig();
config.enableSassLoader(() => {}, { resolve_url_loader: false });
config.enableSassLoader(() => {}, { resolveUrlLoader: false });

expect(config.useSassLoader).to.be.true;
expect(config.sassOptions.resolve_url_loader).to.be.false;
expect(config.sassOptions.resolveUrlLoader).to.be.false;
});

it('Pass invalid config', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/loaders/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('loaders/sass', () => {
it('getLoaders() without resolve-url-loader', () => {
const config = createConfig();
config.enableSassLoader(() => {}, {
resolve_url_loader: false,
resolveUrlLoader: false,
});
config.enableSourceMaps(false);

Expand Down
2 changes: 2 additions & 0 deletions test/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ describe('logger', () => {
'debug',
'recommendation',
'warning',
'deprecation',
];
const testString = 'TEST MESSAGE';
const expectedMessages = {
debug: [testString],
recommendation: [testString],
warning: [testString],
deprecation: [testString],
};

logger.quiet();
Expand Down
0