|
1 |
| -const path = require("path"); |
2 |
| -const webpack = require("webpack"); |
3 |
| -const CopyWebpackPlugin = require("copy-webpack-plugin"); |
4 |
| -const nodeExternals = require("webpack-node-externals"); |
5 |
| -const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin"); |
6 |
| -const config = require("./config/config"); |
7 |
| - |
8 |
| -if (process.env.NODE_ENV == null) { |
9 |
| - process.env.NODE_ENV = "development"; |
10 |
| -} |
11 |
| -const ENV = (process.env.ENV = process.env.NODE_ENV); |
12 |
| - |
13 |
| -const envConfig = config.load(ENV); |
14 |
| -config.log(envConfig); |
15 |
| - |
16 |
| -const moduleRules = [ |
17 |
| - { |
18 |
| - test: /\.ts$/, |
19 |
| - use: "ts-loader", |
20 |
| - exclude: path.resolve(__dirname, "node_modules"), |
21 |
| - }, |
22 |
| -]; |
23 |
| - |
24 |
| -const plugins = [ |
25 |
| - new CopyWebpackPlugin({ |
26 |
| - patterns: [{ from: "./src/locales", to: "locales" }], |
27 |
| - }), |
28 |
| - new webpack.DefinePlugin({ |
29 |
| - "process.env.BWCLI_ENV": JSON.stringify(ENV), |
30 |
| - }), |
31 |
| - new webpack.BannerPlugin({ |
32 |
| - banner: "#!/usr/bin/env node", |
33 |
| - raw: true, |
34 |
| - }), |
35 |
| - new webpack.IgnorePlugin({ |
36 |
| - resourceRegExp: /^encoding$/, |
37 |
| - contextRegExp: /node-fetch/, |
38 |
| - }), |
39 |
| - new webpack.EnvironmentPlugin({ |
40 |
| - ENV: ENV, |
41 |
| - BWCLI_ENV: ENV, |
42 |
| - FLAGS: envConfig.flags, |
43 |
| - DEV_FLAGS: envConfig.devFlags, |
44 |
| - }), |
45 |
| - new webpack.IgnorePlugin({ |
46 |
| - resourceRegExp: /canvas/, |
47 |
| - contextRegExp: /jsdom$/, |
48 |
| - }), |
49 |
| -]; |
50 |
| - |
51 |
| -const webpackConfig = { |
52 |
| - mode: ENV, |
53 |
| - target: "node", |
54 |
| - devtool: ENV === "development" ? "eval-source-map" : "source-map", |
55 |
| - node: { |
56 |
| - __dirname: false, |
57 |
| - __filename: false, |
58 |
| - }, |
59 |
| - entry: { |
60 |
| - bw: "./src/bw.ts", |
61 |
| - }, |
62 |
| - optimization: { |
63 |
| - minimize: false, |
64 |
| - }, |
65 |
| - resolve: { |
66 |
| - extensions: [".ts", ".js"], |
67 |
| - symlinks: false, |
68 |
| - modules: [path.resolve("../../node_modules")], |
69 |
| - plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json" })], |
70 |
| - }, |
71 |
| - output: { |
72 |
| - filename: "[name].js", |
73 |
| - path: path.resolve(__dirname, "build"), |
74 |
| - clean: true, |
75 |
| - }, |
76 |
| - module: { rules: moduleRules }, |
77 |
| - plugins: plugins, |
78 |
| - externals: [ |
79 |
| - nodeExternals({ |
80 |
| - modulesDir: "../../node_modules", |
81 |
| - allowlist: [/@bitwarden/], |
82 |
| - }), |
83 |
| - ], |
84 |
| - experiments: { |
85 |
| - asyncWebAssembly: true, |
86 |
| - }, |
87 |
| -}; |
88 |
| - |
89 |
| -module.exports = webpackConfig; |
| 1 | +// For backward compatibility with existing npm scripts |
| 2 | +module.exports = require("./webpack.npm.config.js"); |
0 commit comments