UNPKG

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