-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.ts
46 lines (45 loc) · 1.07 KB
/
webpack.config.ts
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
import path from 'path'
import webpack from 'webpack';
import fs from 'fs'
// FROM: http://jlongster.com/Backend-Apps-with-Webpack--Part-I#p28
const nodeModules = {};
fs.readdirSync('node_modules')
.filter(item => ['.bin'].indexOf(item) === -1) // exclude the .bin folder
.forEach((mod) => {
nodeModules[mod] = 'commonjs ' + mod;
});
const config:webpack.Configuration = {
mode: "production",
entry: "./src/index.ts",
target: "node",
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
library: 'webpackPluginImageTransformWebpAndMini',
libraryExport: "default",
libraryTarget: "commonjs2"
},
resolve: {
extensions: ['.js', '.ts']
},
node: {
fs: "empty",
child_process: "empty",
__filename: false,
__dirname: false
},
externals: nodeModules,
module: {
rules: [{
test: /\.ts$/,
use: {
loader: 'ts-loader',
options: {
context: __dirname,
configFile: require.resolve('./tsconfig.json')
}
}
}]
}
}
module.exports = config