forked from ForgeRock/forgerock-javascript-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
65 lines (61 loc) · 1.71 KB
/
webpack.config.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const { exec } = require('child_process');
const path = require('path');
const TsConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
module.exports = (env) => {
const isDev = env.DEV === 'yes';
const plugins = [
new webpack.WatchIgnorePlugin([/bundles|docs|lib|lib\-esm|samples/]),
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
const cmds = [
'cpy ./tests/e2e/env.config.ts ./tests/e2e/server --rename=env.config.copy.mjs',
'copyup ./bundles/index.js* ./tests/e2e/app',
'copyup ./bundles/index.js* ./samples/_static/js/',
];
for (const cmd of cmds) {
exec(cmd, (err, stdout, stderr) => {
if (err) {
console.error(err);
return;
}
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
}
});
},
},
];
return {
devtool: isDev ? 'eval-source-map' : 'source-map',
entry: './src/index.ts',
mode: isDev ? 'development' : 'production',
module: {
rules: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
query: {
declaration: false,
},
},
],
},
output: {
filename: 'index.js',
library: 'forgerock',
libraryTarget: 'umd',
path: path.resolve('./bundles'),
umdNamedDefine: true,
},
plugins,
resolve: {
extensions: ['.js', '.ts'],
plugins: [new TsConfigPathsPlugin()],
},
watch: isDev,
};
};