-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
84 lines (79 loc) · 2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const path = require("path");
const webpack = require("webpack");
const envify = require("process-envify");
const env = require("./env");
// const pkg = require('./package');
const SOURCE_ROOT = path.join(__dirname, "src");
const DISTRIBUTION_ROOT = path.join(__dirname, "public");
module.exports = ({ prod = false } = {}) => ({
target: 'node',
mode: prod ? "production" : "development",
context: SOURCE_ROOT,
entry: "./extension.js",
output: {
path: DISTRIBUTION_ROOT,
// filename: "main.js",
// filename: prod ? "[name].[hash].js" : "[name].js",
// chunkFilename: prod ? "[id].[chunkhash].js" : "[name].js",
publicPath: "/",
filename: 'extension.js',
// libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: 'source-map',
externals: {
vscode: "commonjs vscode" // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}]
},
].filter(Boolean)
},
resolve: {
extensions: [".mjs", ".js", ".svelte"],
alias: {
"~": SOURCE_ROOT
}
},
plugins: [
new webpack.DefinePlugin(envify(env)),
].filter(Boolean),
optimization: {
splitChunks: {
cacheGroups: {
common: {
name: "common",
chunks: "initial",
minChunks: 2
},
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "all"
}
}
},
runtimeChunk: {
name: "manifest"
}
},
devServer: {
contentBase: DISTRIBUTION_ROOT,
historyApiFallback: true,
host: env.HOST_NAME,
hot: true,
inline: true,
overlay: true,
port: env.SITE_PORT
},
devtool: prod ? "hidden-source-map" : "cheap-module-eval-source-map"
});