-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvue.config.js
141 lines (122 loc) · 4.71 KB
/
vue.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const { defineConfig } = require("@vue/cli-service");
const CopyPlugin = require("copy-webpack-plugin");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const path = require("path");
module.exports = defineConfig({
devServer: {
headers: {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
},
},
publicPath: (process.env.NODE_ENV === "development") ? undefined : "./",
// publicPath: "/apps/molmoda/beta/",
transpileDependencies: true,
productionSourceMap: true,
parallel: 4,
configureWebpack: (config) => {
// if (process.env.NODE_ENV === "development") {
// } else
if (process.env.NODE_ENV === "docs") {
config.optimization.minimize = false;
} else {
// So currently runs in development and production...
config.output.devtoolModuleFilenameTemplate = (info) =>
info.resourcePath.match(/\.vue$/) &&
!info.identifier.match(/type=script/) // this is change ✨
? `webpack-generated:///${info.resourcePath}?${info.hash}`
: `webpack-yourCode:///${info.resourcePath}`;
config.output.devtoolFallbackModuleFilenameTemplate =
"webpack:///[resource-path]?[hash]";
}
// Handle source maps
if (process.env.NODE_ENV === "development") {
// Embeds souce maps in code. Faster build times. Good for development
config.devtool ="eval-source-map";
} else {
// Production
// Separate map files
config.devtool ="source-map";
}
// else {
// // Production
// // console.log("product!")
// config.stats = "verbose";
// config.devtool = "eval-source-map"; // false;
// }
// ChatGPT says this will speed up builds
config.cache = {
type: "filesystem",
cacheDirectory: path.resolve(__dirname, ".temp_cache"),
};
config.resolve.fallback = {
fs: false,
tls: false,
net: false,
path: require.resolve("path-browserify"),
zlib: false,
http: false,
https: false,
stream: false,
crypto: false,
os: require.resolve("os-browserify/browser"),
perf_hooks: false,
};
config.resolve.symlinks = false;
config.plugins.push(
new CopyPlugin({
patterns: [
// Rather than copy files in node_modules to public, just
// copy here. This is so if you update via npm, you'll still
// get the latest versions.
{
from: "src/Testing/mols/4WP4.pdb",
to: "4WP4.pdb",
},
{
from: "node_modules/@rdkit/rdkit/dist",
to: "js/rdkitjs",
},
// Below is for webworker
{
from: "node_modules/@rdkit/rdkit/dist/RDKit_minimal.wasm",
to: "js/RDKit_minimal.wasm",
},
// Below is to get kekulejs open babel to work. TODO: Would
// be great just to use standard molmoda openbabel, but we'd
// need to get cml format working.
// {
// from: "node_modules/kekule/dist/extra",
// to: "js/extra",
// }
],
})
);
config.plugins.push(
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /a\.js|node_modules/,
// include specific files based on a RegExp
// include: /src/,
// add errors to webpack instead of warnings
failOnError: true,
// allow import cycles that include an asyncronous import,
// e.g. via import(/* webpackMode: "weak" */ './file.js')
allowAsyncCycles: false,
// set the current working directory for displaying module paths
cwd: process.cwd(),
})
);
config.optimization.splitChunks = {
minSize: 10000,
maxSize: 250000,
};
config.optimization.runtimeChunk = true;
},
pluginOptions: {
webpackBundleAnalyzer: {
openAnalyzer: false,
analyzerMode: "static",
},
},
});