forked from wdzeng/shopee-coins-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
42 lines (38 loc) · 1.04 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
import fs from 'node:fs'
import path from 'node:path'
import url from 'node:url'
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
import webpack from 'webpack'
const projectRootPath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)))
const packageJson = JSON.parse(fs.readFileSync(path.resolve(projectRootPath, 'package.json')))
const version = packageJson.version
const outputDir = path.resolve(projectRootPath, 'dist')
const versionPlugin = new webpack.DefinePlugin({ 'process.env.VERSION': JSON.stringify(version) })
export default {
mode: 'production',
entry: './src/index.ts',
output: {
filename: 'index.cjs',
path: outputDir,
clean: true
},
resolve: {
plugins: [new TsconfigPathsPlugin()],
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
target: 'node',
experiments: {
topLevelAwait: true
},
externals: ['utf-8-validate', 'bufferutil'],
plugins: [versionPlugin]
}