Skip to content

Commit 20e9516

Browse files
Webpack configuration to build minified scripts for browsers
1 parent 1ae0fba commit 20e9516

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

webpack.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const path = require('path')
2+
const packageJson = require('./package.json')
3+
4+
// production config minimizes the code
5+
const productionConfig = {
6+
mode: 'production',
7+
8+
// application entry point
9+
entry: './lib/index.js',
10+
11+
// Output configuration
12+
output: {
13+
path: path.resolve(__dirname, 'lib'),
14+
filename: `sqlitecloud.v${packageJson.version}.js`,
15+
library: 'sqlitecloud',
16+
libraryTarget: 'umd',
17+
globalObject: 'this'
18+
},
19+
20+
optimization: {
21+
minimize: true
22+
},
23+
24+
// add mock 'tls' module
25+
resolve: {
26+
fallback: {
27+
tls: false // tell Webpack to ignore "tls"
28+
}
29+
}
30+
}
31+
32+
// development config does not minimize the code
33+
const devConfig = JSON.parse(JSON.stringify(productionConfig))
34+
devConfig.mode = 'development'
35+
devConfig.optimization.minimize = false
36+
devConfig.output.filename = `sqlitecloud.v${packageJson.version}.dev.js`
37+
38+
module.exports = [productionConfig, devConfig]

0 commit comments

Comments
 (0)