forked from remoteit/socket-link.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
46 lines (45 loc) · 1.03 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
const {RawSource} = require('webpack-sources')
const path = require('path')
module.exports = {
target: 'node',
mode: 'production',
entry: {
index: './src/index.ts',
cli: './src/cli.ts'
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
library: {type: 'commonjs'}
},
optimization: {
minimize: true
},
plugins: [
{
apply: (compiler) => {
compiler.hooks.emit.tapAsync('AddShebangPlugin', (compilation, callback) => {
const assetName = 'cli.js'
if (compilation.assets[assetName]) {
let originalSource = compilation.assets[assetName].source()
originalSource = '#!/usr/bin/env node\n' + originalSource
compilation.assets[assetName] = new RawSource(originalSource)
}
callback()
})
}
}
]
}