forked from zodern/melte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscss-processor.js
39 lines (35 loc) · 1.06 KB
/
scss-processor.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
import { dirname, resolve } from 'path';
const appdir = resolve(process.cwd());
const includePaths = [
appdir,
resolve(appdir, 'node_modules'),
];
export async function processCode(file, filename, { content }) {
const transformer = require('svelte-preprocess/dist/transformers/scss').transformer;
try {
return await transformer({
content,
filename,
options: {
includePaths,
sourceMap: true,
importer: [
function (url, prev, done) {
done({
file: resolve(
url.indexOf('.') === 0
? dirname(filename)
: appdir,
url.replace(/^\//, '')
)
});
}
]
}
});
} catch (e) {
e.message += `\n${e.stack}`;
file.error(e);
return { code: '' };
}
}