1 | import path from 'path';
|
2 | import webpack from 'webpack';
|
3 | import MemoryFS from 'memory-fs';
|
4 |
|
5 | export default function test(fixture, options = {}) {
|
6 | const compiler = webpack({
|
7 | context: __dirname,
|
8 | entry: `./${fixture}`,
|
9 | output: {
|
10 | filename: 'test-out.js',
|
11 | path: path.resolve(__dirname),
|
12 | },
|
13 | module: {
|
14 | rules: [
|
15 | {
|
16 | test: /\.css$/,
|
17 | use: [
|
18 | {loader: path.resolve(__dirname, '../../index.js'), options},
|
19 | {loader: 'css-loader'},
|
20 | ],
|
21 | },
|
22 | ],
|
23 | },
|
24 | });
|
25 |
|
26 | compiler.outputFileSystem = new MemoryFS();
|
27 |
|
28 | return new Promise((resolve, reject) => {
|
29 | compiler.run((err, stats) => {
|
30 | if (err) {
|
31 | reject(err);
|
32 | }
|
33 |
|
34 | resolve(stats);
|
35 | });
|
36 | });
|
37 | }
|