-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (36 loc) · 979 Bytes
/
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
const fs = require('fs');
const path = require('path');
const {validate} = require('schema-utils');
const schema = {
type: 'object',
properties: {
test: {
type: 'string',
}
}
}
export default class EnvRewritterPlugin {
static defaultOptions = {
files: ['./env', '.env.local'],
}
constructor(files = []) {
validate(schema, files, {
name: 'Env Rewritter Plugin',
baseDataPath: 'files',
});
this.files = [
...new Set(
[ ...EnvRewritterPlugin.defaultOptions.files, ...this.files],
),
];
}
apply(compiler) {
const pluginName = EnvRewritterPlugin.name;
const { webpack } = compiler;
const { Compilation } = webpack;
const { RawSource } = webpack.sources;
compiler.hooks.environment.tap(pluginName, () => {
console.log('dddd', process.env);
});
}
}