UNPKG

746 BJavaScriptView Raw
1"use strict";
2
3const cssLoader = require('css-loader');
4
5const postcssLoader = require('postcss-loader');
6
7const postcssNested = require('postcss-nested');
8
9function postcss(loader, css, map, meta, cb) {
10 const ctx = { ...loader
11 };
12
13 ctx.async = () => cb;
14
15 ctx.loaderIndex++;
16 ctx.query = {
17 plugins: [postcssNested()]
18 };
19 postcssLoader.call(ctx, css, map, meta);
20}
21
22module.exports = function loader(css, map, meta) {
23 const done = this.async();
24 postcss(this, css, map, meta, (err, ...args) => {
25 if (err) {
26 done(err);
27 return;
28 }
29
30 const ctx = { ...this
31 };
32 ctx.query = { ...this.query,
33 modules: this.query.modules || true,
34 importLoaders: 0
35 };
36 cssLoader.call(ctx, ...args);
37 });
38};
\No newline at end of file