Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 6414aea

Browse files
committed
fix: 🐛 configure webpack to build separately for browser
1 parent 2aeecc6 commit 6414aea

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ scripts/*
44
sandbox.ts
55
test_utils/*
66
examples/*
7+
webpack.*

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"lib/**/*"
1111
],
1212
"main": "lib/index.js",
13+
"browser": "lib/index.browser.js",
1314
"types": "lib/index.d.ts",
1415
"scripts": {
1516
"start": "webpack-dev-server --config=webpack.config.dev.js",

webpack.config.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,34 @@ const merge = require('webpack-merge');
33

44
const baseConfig = require('./webpack.base');
55

6-
const buildConfig = merge.smart(baseConfig, {
6+
const browserConfig = merge.smart(baseConfig, {
77
devtool: 'source-map',
88
mode: 'production',
99
entry: path.resolve(__dirname, './src/index.ts'),
10+
target: 'web',
11+
output: {
12+
pathinfo: true,
13+
filename: 'index.browser.js',
14+
path: path.resolve(__dirname, 'lib'),
15+
library: '@polymathnetwork/contract-wrappers',
16+
libraryTarget: 'commonjs2',
17+
globalObject: 'this',
18+
}
19+
})
20+
21+
const nodeConfig = merge.smart(baseConfig, {
22+
devtool: 'source-map',
23+
mode: 'production',
24+
entry: path.resolve(__dirname, './src/index.ts'),
25+
target: 'node',
1026
output: {
1127
pathinfo: true,
1228
filename: 'index.js',
1329
path: path.resolve(__dirname, 'lib'),
1430
library: '@polymathnetwork/contract-wrappers',
15-
libraryTarget: 'commonjs2'
31+
libraryTarget: 'commonjs2',
32+
globalObject: 'this',
1633
}
1734
});
1835

19-
module.exports = buildConfig;
36+
module.exports = [browserConfig, nodeConfig];

0 commit comments

Comments
 (0)