UNPKG

599 BJavaScriptView Raw
1const postcss = require('postcss');
2const localRequire = require('../utils/localRequire');
3const Asset = require('../Asset');
4
5class SSSAsset extends Asset {
6 constructor(name, options) {
7 super(name, options);
8 this.type = 'css';
9 }
10
11 async generate() {
12 let sugarss = await localRequire('sugarss', this.name);
13
14 await this.loadIfNeeded();
15
16 let {css} = await postcss().process(this.contents, {
17 from: this.name,
18 to: this.name,
19 parser: sugarss
20 });
21
22 return [
23 {
24 type: 'css',
25 value: css
26 }
27 ];
28 }
29}
30
31module.exports = SSSAsset;