forked from 0xPolygon/polygon-token-assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
74 lines (72 loc) · 2.02 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
66
67
68
69
70
71
72
73
74
const path = require('path');
const { merge } = require('webpack-merge');
var webpack = require('webpack');
// const SmartBannerPlugin = require('smart-banner-webpack-plugin');
// const banner = require('./../license');
// const CopyPlugin = require('copy-webpack-plugin');
const isDev = process.env.NODE_ENV;
const baseConfig = {
entry: "./build/index.ts",
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader'
}
}
]
},
resolve: {
extensions: ['.js', '.ts']
},
// node: {
// global: false,
// __filename: false,
// __dirname: false,
// },
plugins: [
// new SmartBannerPlugin(banner),
// new CopyPlugin({
// patterns: [
// { from: 'build_helper', to: '' },
// ],
// }),
]
}
function createConfigsForAllLibraryTarget() {
const libraryTarget = [
{
type: "var",
name: isDev ? 'lib.js' : 'lib.min.js'
}, {
type: "commonjs2",
name: isDev ? 'lib.commonjs2.js' : 'lib.commonjs2.min.js'
}
];
const getConfigForTaget = function (target) {
return {
output: {
path: path.join(process.cwd(), "./dist"),
filename: target.name,
library: 'PolygonTokenAssets',
// libraryExport: 'default',
libraryTarget: target.type
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': process.env.NODE_ENV
}),
],
mode: process.env.NODE_ENV,
devtool: 'source-map',
}
}
var configs = [];
libraryTarget.forEach(function (target) {
configs.push(merge(baseConfig, getConfigForTaget(target)));
})
return configs;
}
module.exports = createConfigsForAllLibraryTarget()