Skip to content

Commit 25bff9b

Browse files
feat(plugins/import): add @import filter support (options.import) (#656)
1 parent 2202572 commit 25bff9b

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export default function loader(css, map, meta) {
2828
// Loader Mode (Async)
2929
const cb = this.async();
3030
const file = this.resourcePath;
31+
<<<<<<< HEAD
3132

33+
=======
34+
35+
>>>>>>> feat(plugins/import): add `@import` filter support (`options.import`) (#656)
3236
// Loader Options
3337
const options = Object.assign({}, DEFAULTS, getOptions(this));
3438

@@ -78,7 +82,7 @@ export default function loader(css, map, meta) {
7882
map,
7983
to: file,
8084
})
81-
.then(({ css, map, messages }) => {
85+
.then(({ root, css, map, messages }) => {
8286
if (meta && meta.messages) {
8387
messages = messages.concat(meta.messages);
8488
}
@@ -116,15 +120,30 @@ export default function loader(css, map, meta) {
116120

117121
return exports;
118122
}, '');
123+
124+
imports = imports ? `// CSS Imports\n${imports}\n` : false
125+
exports = exports ? `// CSS Exports\n${exports}\n` : false
126+
css = `// CSS\nexport default \`${css}\``
119127

120128
imports = imports ? `// CSS Imports\n${imports}\n` : false;
121129
exports = exports ? `// CSS Exports\n${exports}\n` : false;
122130
css = `// CSS\nexport default \`${css}\``;
123131

124132
// TODO(michael-ciniawsky)
125133
// triage if and add CSS runtime back
134+
<<<<<<< HEAD
126135
const result = [imports, exports, css].filter(Boolean).join('\n');
127136

137+
=======
138+
const result = [
139+
imports,
140+
exports,
141+
css
142+
]
143+
.filter(Boolean)
144+
.join('\n');
145+
146+
>>>>>>> feat(plugins/import): add `@import` filter support (`options.import`) (#656)
128147
cb(null, result, map ? map.toJSON() : null);
129148

130149
return null;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import css from './fixture.css';
2+
3+
export default css;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import css from './fixture.css';
2+
3+
export default css;

0 commit comments

Comments
 (0)