forked from rubenspgcavalcante/webpack-extension-reloader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
77 lines (75 loc) · 1.95 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
const path = require("path");
const { BannerPlugin } = require("webpack");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const pack = require("./package.json");
const { isDevelopment, isProduction, test } = require("./src/utils/env");
const mode = isDevelopment ? "development" : "production";
const packName = "webpack-extension-reloader";
module.exports = (env = { analyze: false }) => ({
mode,
target: "node",
entry: test({ tests: "./specs/index.ts" }) || {
[packName]: "./src/index.ts",
[`${packName}-cli`]: "./client/index.ts"
},
devtool: "inline-source-map",
output: {
publicPath: ".",
path: path.resolve(__dirname, "./dist"),
filename: "[name].js",
libraryTarget: "umd"
},
plugins: [
env.analyze && isProduction(new BundleAnalyzerPlugin({ sourceMap: true })),
new BannerPlugin({
banner: `/// <reference path="../typings/${packName}.d.ts" />`,
raw: true,
entryOnly: true,
include: "webpack-extension-reloader"
}),
new BannerPlugin({
banner: "#!/usr/bin/env node",
raw: true,
entryOnly: true,
include: `${packName}-cli`
})
].filter(plugin => !!plugin),
externals: [
...Object.keys(pack.dependencies),
"webpack",
"webpack-extension-reloader"
],
resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"],
mainFiles: ["index"],
extensions: [".ts", ".tsx", ".js"]
},
optimization: {
minimize: false,
nodeEnv: false
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ["babel-loader"]
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
loaders: ["babel-loader", "ts-loader"]
},
{
test: /\.json$/,
exclude: /node_modules/,
loaders: ["json-loader"]
},
{
test: /\.txt$/,
exclude: /node_modules/,
loaders: ["raw-loader"]
}
]
}
});