You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// cacheMap stores { url => contents }, you can easily persist it in file system - see https://github.com/hyrious/esbuild-plugin-http
10
10
letcacheMap=newMap();
11
11
constfs=require('fs');
12
12
constpath=require("path");
13
13
14
+
// Get arguments from npm script (such as --pathprefix) - https://reflect.run/articles/sending-command-line-arguments-to-an-npm-script/
15
+
constparseArgs=(args)=>{
16
+
constparsedArgs={};
17
+
18
+
args.forEach((arg)=>{
19
+
constparts=arg.split("=");
20
+
21
+
parsedArgs[parts[0].slice(2)]=parts[1];
22
+
});
23
+
24
+
returnparsedArgs;
25
+
};
26
+
27
+
constnpmScriptArgs=parseArgs(process.argv);
28
+
29
+
// pathPrefix and defineEnv const's access the environment variable PATHPREFIX set by the npm scripts (in the package.json) which is passed to solid-js by esbuild.js. Esbuild defines the environmental variables to pass through to solid-js app using the define config.
allowOverwrite: !isProd,// overwrite dist/app/style.css when in dev mode
19
42
bundle: true,
20
43
minify: isProd,
44
+
write: !isProd,// this is required for the gzipPlugin to work
21
45
treeShaking: isProd,
22
46
outdir: './dist/app',
23
47
sourcemap: !isProd,
24
48
target: isProd ? 'es6' : 'esnext',
25
49
metafile: true,
50
+
define: defineEnv,
26
51
plugins: [
27
-
// Runs develeopment build (skips purgingcss) if isProd = false when ELEVENTY_ENV != 'prod'
52
+
// To run development/staging build (skips purgingcss) if isProd = false when ELEVENTY_ENV != 'prod'.
53
+
// This is implimented in the package.json scripts
28
54
http({
29
55
filter: (url)=>true,
30
56
schemes: { default_schemes },
@@ -48,6 +74,15 @@ const esbuildOpts = {
48
74
]
49
75
}
50
76
77
+
// If isProd include gzipPlugin. This is pushed into esBuildOpts.plugins because in dev/staging mode the esBuild's write api must be true. But the gzipPlugin requires it to be false.
0 commit comments