Skip to content

Commit

Permalink
Upgrade to webpack 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tmair committed Dec 22, 2016
1 parent 480a7cb commit 1414036
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ function ExtractTextPlugin(options) {
}
module.exports = ExtractTextPlugin;

// modified from webpack/lib/LoadersList.js
function getLoaderWithQuery(loader) {
if(isString(loader)) return loader;
if(!loader.query) return loader.loader;
var query = isString(loader.query) ? loader.query : JSON.stringify(loader.query);
return loader.loader + "?" + query;
function getLoaderWithObject(loader) {
if (isString(loader)) {
return {loader: loader};
}

return loader;
}

function mergeOptions(a, b) {
Expand Down Expand Up @@ -198,8 +198,7 @@ ExtractTextPlugin.prototype.extract = function(options) {
delete options.fallbackLoader;
return [this.loader(options)]
.concat(before, loader)
.map(getLoaderWithQuery)
.join("!");
.map(getLoaderWithObject);
}

ExtractTextPlugin.extract = ExtractTextPlugin.prototype.extract.bind(ExtractTextPlugin);
Expand Down

2 comments on commit 1414036

@renarsvilnis
Copy link

Choose a reason for hiding this comment

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

Hmm hasn't that removed backwards compatibility for Webpack 1 users?

@tmair
Copy link
Owner Author

@tmair tmair commented on 1414036 Dec 23, 2016

Choose a reason for hiding this comment

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

@renarsvilnis That might be the case. I just was not sure if I am breaking anything with this change. The tests run fine, but maybe a test for this case is missing.
What I did think was that the 2.0.0 version of the plugin was intended to support only webpack2. At least the peerDependency of webpack@^2.1.0-beta.19 suggests that. But i was not sure about that so I did not file a PR.
With this change however a configuration like this works:

                use: ExtractTextPlugin.extract({
                    loader: ['css-loader', 'postcss-loader', 'sass-loader'] // TODO sourcemaps
                })

Without the change it is not able to find the extract-text-plugin loader and will fail with a cryptic message.

Please sign in to comment.