-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
56 lines (47 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
// eslint-disable-next-line node/no-unpublished-require
const Plugin = require('ember-css-modules/lib/plugin');
module.exports = {
name: 'ember-css-modules-sass',
shouldIncludeChildAddon(addon) {
// Don't infinitely recurse – it's the dummy test app that depends on dummy-addon, not this addon itself
return addon.name.indexOf('dummy') === -1;
},
createCssModulesPlugin(parent) {
return new SassPlugin(parent);
}
};
class SassPlugin extends Plugin {
constructor(parent) {
super(parent);
this._verifySetup(parent);
}
config() {
return {
intermediateOutputPath: this._intermediateOutputPath(),
extension: 'scss',
postcssOptions: {
syntax: require('postcss-scss')
}
};
}
_intermediateOutputPath() {
return this.isForAddon()
? 'addon.scss'
: this._hasEmbroider()
? 'app.scss'
: 'app/styles/app.scss';
}
_hasEmbroider() {
return '@embroider/compat' in (this.parent.pkg.devDependencies || {});
}
_verifySetup(parent) {
let hasEmberCliSass = parent.addons.some(addon => addon.name === 'ember-cli-sass');
if (!hasEmberCliSass) {
parent.ui.writeWarnLine(
`Detected ember-css-modules-sass without ember-cli-sass. ` +
`You'll need both in order for Sass processing to work correctly.`
);
}
}
}