-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.cjs
52 lines (51 loc) · 1.43 KB
/
webpack.config.cjs
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
// webpack.config.cjs
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
module.exports = {
target: "node",
entry: "./src/extension.js", // The entry point for your extension
output: {
path: path.resolve(__dirname, "dist"),
filename: "extension.js", // Output the bundled extension
libraryTarget: "commonjs2",
},
devtool: "source-map",
externals: {
vscode: "commonjs vscode", // Exclude vscode module from bundling
},
resolve: {
extensions: [".js", ".json"], // Ensure .js files are resolved
},
module: {
rules: [
{
test: /\.js$/, // Apply the rule to all .js files
exclude: /node_modules/,
use: {
loader: "babel-loader", // Use Babel loader for transpiling
options: {
presets: ["@babel/preset-env"],
},
},
},
],
},
plugins: [
new CopyPlugin({
patterns: [
{
from: "src/*.js", // Copy all .js files from src to dist
to: path.resolve(__dirname, "dist/[name].js"), // Keep the same file names in dist
},
{
from: "resources/**/*", // Copy resources folder (e.g., icon.png)
to: path.resolve(__dirname, "dist/[path][name][ext]"),
},
],
}),
],
mode: process.env.NODE_ENV === "production" ? "production" : "development",
optimization: {
minimize: true, // Minify the output for production builds
},
};