-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
64 lines (62 loc) · 1.75 KB
/
webpack.config.js
File metadata and controls
64 lines (62 loc) · 1.75 KB
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
import path from "path";
import HtmlWebpackPlugin from "html-webpack-plugin";
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
import webpack from "webpack";
export default async (env, options) => {
const dev = options.mode === "development";
const config = {
optimization: {
minimize: !dev,
splitChunks: {
chunks: "all",
},
},
devtool: dev ? "source-map" : false,
entry: "./js/ispy.js",
target: ["web", "es5"],
output: {
filename: "masterclass_[name].js", // Output each file with its name
path: path.resolve("dist/assets/js/"),
clean: true,
},
resolve: {
extensions: [".ts", ".tsx", ".html", ".js"],
},
plugins: [
new HtmlWebpackPlugin({
filename: "../../index.html",
template: "./index.html",
inject: "body",
}),
// new CopyWebpackPlugin({
// patterns: [
// {
// from: "node_modules/jquery/dist/jquery.min.js",
// to: "jquery.min.js",
// },
// {
// from: "node_modules/stupid-table-plugin/stupidtable.min.js",
// to: "stupidtable.min.js",
// },
// {
// from: "node_modules/jquery.scrollintoview/jquery.scrollintoview.js",
// to: "jquery.scrollintoview.js",
// },
// ],
// }),
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(!dev),
}),
],
};
if (env && env.analyze) {
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: "static", // generates a file
openAnalyzer: true, // opens the report in browser
reportFilename: path.resolve("dist", "bundle-report.html"),
}),
);
}
return config;
};