diff --git a/README.md b/README.md index 676fb3f0..2521245b 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,36 @@ module.exports = { }; ``` +## Advanced options + +If you need to pass [more advanced options](https://github.com/webpack/css-loader/pull/348), especially those which cannot be stringified, you can also define an `cssLoader`-property on your `webpack.config.js`: + +``` javascript +module.exports = { + module: { + loaders: [{ + test: /\.css$/, + loader: "style-loader!css-loader" + }] + }, + cssLoader: {} +}; +``` + +If you need to define two different loader configs, you can also change the config's property name via `css?config=otherCssLoaderConfig`: + +``` javascript +module.exports = { + module: { + loaders: [{ + test: /\.css$/, + loader: "style-loader!css-loader?config=otherCssLoaderConfig" + }] + }, + otherCssLoaderConfig: {} +}; +``` + ### 'Root-relative' urls For urls that start with a `/`, the default behavior is to not translate them: diff --git a/lib/getLoaderConfig.js b/lib/getLoaderConfig.js new file mode 100644 index 00000000..7bab8473 --- /dev/null +++ b/lib/getLoaderConfig.js @@ -0,0 +1,5 @@ +var loaderUtils = require("loader-utils"); + +module.exports = function getLoaderConfig(loaderContext) { + return loaderUtils.getLoaderConfig(loaderContext, 'cssLoader') || {}; +}; diff --git a/lib/loader.js b/lib/loader.js index 7574ba15..f6a9d79d 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -7,12 +7,13 @@ var loaderUtils = require("loader-utils"); var processCss = require("./processCss"); var getImportPrefix = require("./getImportPrefix"); var compileExports = require("./compile-exports"); +var getLoaderConfig = require("./getLoaderConfig"); module.exports = function(content, map) { if(this.cacheable) this.cacheable(); var callback = this.async(); - var query = loaderUtils.parseQuery(this.query); + var query = getLoaderConfig(this); var root = query.root; var moduleMode = query.modules || query.module; var camelCaseKeys = query.camelCase || query.camelcase;