-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.js
126 lines (123 loc) · 3.13 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const path = require("path");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const config = {
mode: process.env.NODE_ENV || "development",
entry: {
datamonkey: ["./src/entry.js"],
},
output: {
path: path.resolve(__dirname, "public/assets/js/"),
filename: "[name].js",
clean: false, // Cleans output directory before building
},
devtool: process.env.NODE_ENV === "production" ? false : "source-map",
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
name: "vendors~datamonkey",
test: /[\\/]node_modules[\\/]/,
chunks: "all",
},
},
},
},
externals: {
jsdom: "window",
},
module: {
rules: [
{
test: /\.(sass|scss|css)$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: { implementation: require("sass") },
},
],
},
{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
},
{
test: /\.(woff|woff2|ttf|eot|svg|jpg|gif)$/,
type: "asset/resource",
generator: {
filename: "assets/[hash][ext][query]",
},
},
{
test: require.resolve("jquery"),
use: [
{
loader: "expose-loader",
options: { exposes: ["$", "jQuery"] },
},
],
},
{
test: require.resolve("underscore"),
use: [
{
loader: "expose-loader",
options: { exposes: ["_"] },
},
],
},
{
enforce: "pre",
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {},
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "../css/[name].css",
chunkFilename: "../css/[id].css",
}),
new webpack.ProvidePlugin({
process: 'process/browser',
$: "jquery",
jQuery: "jquery",
d3: "d3",
_: "underscore",
}),
new CopyWebpackPlugin({
patterns: [
{ from: "node_modules/hivtrace-viz/dist/hivtrace.js" },
{ from: "node_modules/hivtrace-viz/dist/vendor.js", to: "hivtrace-vendor.js" },
],
}),
],
resolve: {
fallback: {
path: require.resolve("path-browserify"),
process: require.resolve("process"),
},
alias: {
dc: path.resolve(__dirname, "node_modules/dc/dc.min.js"),
"dc.css": path.resolve(__dirname, "node_modules/dc/dc.min.css"),
"phylotree.css": path.resolve(__dirname, "node_modules/phylotree/phylotree.css"),
},
extensions: [".json", ".js", ".jsx", ".scss"],
},
};
if (process.env.NODE_ENV === "production") {
config.plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
}
module.exports = config;