-
Notifications
You must be signed in to change notification settings - Fork 318
Expand file tree
/
Copy pathwebpack.config.js
More file actions
70 lines (66 loc) · 2.12 KB
/
Copy pathwebpack.config.js
File metadata and controls
70 lines (66 loc) · 2.12 KB
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
const webpack = require('webpack');
const path = require('path');
// Run with ANALYZE ENV to show bundle size (only works with cjs)
// e.g.: ANALYZE=true npm run build -w @stacks/wallet-sdk
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { DuplicatesPlugin } = require('inspectpack/plugin');
const NODE_ENV_PRODUCTION = 'production';
const NODE_ENV_DEVELOPMENT = 'development';
const isAnalyze = !!process.env.ANALYZE;
const isProduction = process.env.NODE_ENV === NODE_ENV_PRODUCTION;
module.exports = {
mode: isProduction ? NODE_ENV_PRODUCTION : NODE_ENV_DEVELOPMENT,
entry: ['./src/index.ts'],
output: {
library: {
// name: is set in package config
type: isAnalyze ? 'commonjs' : 'umd',
},
filename: 'index.js',
path: path.resolve(process.cwd(), 'dist/umd'),
globalObject: 'this', // recommended for umd bundles in webpack
},
plugins: [
new webpack.ProvidePlugin({
process: require.resolve('process/browser'),
}),
isAnalyze && new DuplicatesPlugin(),
isAnalyze && new BundleAnalyzerPlugin({ analyzerMode: 'static' }),
].filter(Boolean),
optimization: {
minimize: isProduction,
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'esbuild-loader',
options: {
target: 'es2017',
tsconfig: 'tsconfig.build.json',
},
},
],
},
],
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'@stacks/auth': '@stacks/auth/dist/esm',
'@stacks/bns': '@stacks/bns/dist/esm',
'@stacks/common': '@stacks/common/dist/esm',
'@stacks/encryption': '@stacks/encryption/dist/esm',
'@stacks/network': '@stacks/network/dist/esm',
'@stacks/profile': '@stacks/profile/dist/esm',
'@stacks/stacking': '@stacks/stacking/dist/esm',
'@stacks/storage': '@stacks/storage/dist/esm',
'@stacks/transactions': '@stacks/transactions/dist/esm',
'@stacks/wallet-sdk': '@stacks/wallet-sdk/dist/esm',
},
// fallback: is set in package config
},
};