Skip to content

Commit

Permalink
Add option to disable the URL handler
Browse files Browse the repository at this point in the history
  • Loading branch information
XWB committed Jun 11, 2018
1 parent 2a1a18a commit bfec30a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,18 @@ class Encore {
return this;
}

/**
* Call this if you wish to disable the CSS
* url handler.
*
* @returns {Encore}
*/
disableUrlHandling() {
webpackConfig.disableUrlHandling();

return this;
}

/**
* Call this if you wish to disable the default
* images loader.
Expand Down
5 changes: 5 additions & 0 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class WebpackConfig {
this.useForkedTypeScriptTypeChecking = false;
this.useWebpackNotifier = false;
this.useHandlebarsLoader = false;
this.useUrlHandling = true;

// Features/Loaders options
this.sassOptions = {
Expand Down Expand Up @@ -485,6 +486,10 @@ class WebpackConfig {
this.handlebarsConfigurationCallback = callback;
}

disableUrlHandling() {
this.useUrlHandling = false;
}

disableImagesLoader() {
this.useImagesLoader = false;
}
Expand Down
1 change: 1 addition & 0 deletions lib/loaders/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
{
loader: 'css-loader',
options: {
url: webpackConfig.useUrlHandling,
minimize: webpackConfig.isProduction(),
sourceMap: webpackConfig.useSourceMaps,
// when using @import, how many loaders *before* css-loader should
Expand Down
2 changes: 2 additions & 0 deletions test/loaders/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('loaders/css', () => {

const actualLoaders = cssLoader.getLoaders(config);
expect(actualLoaders).to.have.lengthOf(1);
expect(actualLoaders[0].options.url).to.be.true;
expect(actualLoaders[0].options.sourceMap).to.be.true;
expect(actualLoaders[0].options.minimize).to.be.false;
});
Expand All @@ -40,6 +41,7 @@ describe('loaders/css', () => {

const actualLoaders = cssLoader.getLoaders(config);
expect(actualLoaders).to.have.lengthOf(1);
expect(actualLoaders[0].options.url).to.be.true;
expect(actualLoaders[0].options.sourceMap).to.be.false;
expect(actualLoaders[0].options.minimize).to.be.true;
});
Expand Down

0 comments on commit bfec30a

Please sign in to comment.