Closed fkrauthan closed 1 year ago
Having the same issue as well. Running webpack 2.2.1 and
module.exports = { styleLoader: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader!less-loader" }),
I wrote a small helper function.
function encodeLoader(loader) {
if (typeof loader === "string") {
return loader;
}
if (typeof loader.options !== "undefined") {
const query = Object
.keys(loader.options)
.map(function map(param) {
return `${encodeURIComponent(param)}=${encodeURIComponent(loader.options[param])}`;
})
.join("&");
return `${loader.loader}?${query}`;
}
return loader.loader;
}
module.exports = function buildExtractStylesLoader(loaders) {
const extractTextLoader = encodeLoader(loaders[0]);
const fallbackLoader = encodeLoader(loaders[1]);
const restLoaders = loaders
.slice(2)
.map(function map(loader) {
if (typeof loader === "string") {
return loader;
}
return encodeLoader(loader);
});
return [
extractTextLoader,
fallbackLoader,
...restLoaders,
].join("!");
};
So my font-awesome-config.js looks like this
const buildExtractStylesLoader = require("./buildExtractStylesLoader");
const fontAwesomeConfig = require("./font-awesome.config.js");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
fontAwesomeConfig.styleLoader = buildExtractStylesLoader(ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader", "less-loader"],
}));
module.exports = fontAwesomeConfig;
But I feel like there should be a more elegant solution.
P.s.: My function can also deal with options without any trouble as it converts them to query parameters if needed.
The helper function works for me
Hey I am using the latest version of webpack2 and the extract text plugin but I can't get it working.
Any ideas what I need to do? I've already tried the below to versions:
as well as
both resulting in that same error message.