-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathsnowpack.config.cjs
58 lines (55 loc) · 1.55 KB
/
snowpack.config.cjs
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
// Snowpack Configuration File
// See all supported options: https://www.snowpack.dev/reference/configuration
/** @type {import('snowpack').SnowpackUserConfig} */
const config = {
mount: {
// This explicit mapping of the extension dir to the output dir (dist) is required
// for path resolution in tests (at least).
extension: { url: '/' },
},
plugins: [
[
'snowpack-plugin-replace',
{
list: [
// Remove test only exports
{
from: /export.*TestOnly.*\n/,
to: '',
},
// Remove empty exports
{
from: /export {};\n/,
to: '',
},
],
},
],
],
buildOptions: {
out: 'dist',
// The default _snowpack breaks chrome extensions.
metaUrlPath: 'snowpack',
clean: true,
// The extension HTML files don't have doctype strings so this is required.
htmlFragments: true,
// Default to no sourcemaps in prod.
sourcemap: false,
},
testOptions: {
// Files matching these globs will be excluded by default unless NODE_ENV is set to 'test'
files: ['**/test/**/*', '**/*_test.*'],
},
optimize: {
// Chrome 80 required for Optional chaining
// See https://github.com/evanw/esbuild/blob/master/internal/compat/js_table.go
target: 'chrome80',
},
};
if (process.env.NODE_ENV === 'test') {
// Add sourcemaps for easy debugging.
config.buildOptions.sourcemap = 'inline';
// Remove plugin which replaces test only exports.
config.plugins = [];
}
module.exports = config;