generated from sapphiredev/sapphire-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sass-parsing.test.ts
37 lines (33 loc) · 1.22 KB
/
sass-parsing.test.ts
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
import autoprefixer from 'autoprefixer';
import esbuild, { type BuildOptions } from 'esbuild';
import { sassPlugin } from 'esbuild-sass-plugin';
import postcss from 'postcss';
import { esbuildPluginVersionInjector } from '../../../dist/index.js';
import { assertFileContent, buildAbsolutePath } from '../../common/util';
const midConfig: BuildOptions = {
bundle: true,
outdir: buildAbsolutePath('../fixtures/build-mid/css'),
entryPoints: [buildAbsolutePath('../fixtures/build-in/styles.scss')],
plugins: [
sassPlugin({
async transform(source) {
const { css } = await postcss([autoprefixer]).process(source, { from: undefined });
return css;
}
})
]
};
const endConfig: BuildOptions = {
bundle: true,
outdir: buildAbsolutePath('../fixtures/build-out/css'),
entryPoints: [buildAbsolutePath('../fixtures/build-mid/css/styles.css')],
plugins: [esbuildPluginVersionInjector()]
};
describe('SCSS to CSS', () => {
test('GIVEN no plugin options THEN injects version', async () => {
await esbuild.build(midConfig);
await esbuild.build(endConfig);
await assertFileContent('../fixtures/build-mid/css/styles.css');
await assertFileContent('../fixtures/build-out/css/styles.css');
});
});