forked from ForgeRock/forgerock-javascript-sdk-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts.js
84 lines (77 loc) · 2.29 KB
/
webpack.config.ts.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const { exec } = require('child_process');
const path = require('path');
const webpack = require('webpack');
const banner = `
@forgerock/javascript-sdk
index.js
Copyright (c) ${new Date().getFullYear()} ForgeRock. All rights reserved.
This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.
`;
module.exports = (env) => {
const isDev = env.DEV === 'yes';
const plugins = [
new webpack.WatchIgnorePlugin([/css\.d\.ts$/, /bundles|docs|lib|lib\-esm|samples/]),
new webpack.BannerPlugin(banner),
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
const cmds = [
'cpy ./bundles/index.js ./samples/_static/js --rename=fr-sdk-ui.js',
'cpy ./bundles/index.js.map ./samples/_static/js --rename=fr-sdk-ui.js.map',
'cpy ./bundles/index.js ./tests/e2e/site --rename=fr-sdk-ui.js',
'cpy ./bundles/index.js.map ./tests/e2e/site --rename=fr-sdk-ui.js.map',
'cpy ./bundles/index.js ./tests/e2e/app/_static/js --rename=fr-sdk-ui.js',
'cpy ./bundles/index.js.map ./tests/e2e/app/_static/js --rename=fr-sdk-ui.js.map',
];
for (var 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: 'production',
module: {
rules: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
query: {
declaration: false,
},
},
{
test: /\.html$/,
use: 'raw-loader',
},
],
},
optimization: {
minimize: !isDev,
},
output: {
filename: 'index.js',
library: ['forgerock'],
libraryTarget: 'umd',
path: path.resolve('./bundles'),
umdNamedDefine: true,
},
plugins,
resolve: {
extensions: ['.js', '.ts'],
},
watch: isDev,
};
};