UNPKG

1.68 kBPlain TextView Raw
1import path from 'path'
2
3export const DEFAULT_MAIN_FIELDS = [
4 'module',
5 'jsnext:main', // moment still uses this...
6 'jsnext'
7]
8
9export const DEFAULT_EXTENSIONS = [
10 '.mjs',
11 '.js',
12 '.ts',
13 '.jsx',
14 '.tsx',
15 '.json'
16]
17
18export const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/
19
20export const OPTIMIZABLE_ENTRY_RE = /\.(?:m?js|ts)$/
21
22export const SPECIAL_QUERY_RE = /[\?&](?:worker|sharedworker|raw|url)\b/
23
24/**
25 * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
26 */
27export const FS_PREFIX = `/@fs/`
28
29/**
30 * Prefix for resolved Ids that are not valid browser import specifiers
31 */
32export const VALID_ID_PREFIX = `/@id/`
33
34/**
35 * Some Rollup plugins use ids that starts with the null byte \0 to avoid
36 * collisions, but it is not permitted in import URLs so we have to replace
37 * them.
38 */
39export const NULL_BYTE_PLACEHOLDER = `__x00__`
40
41export const CLIENT_PUBLIC_PATH = `/@vite/client`
42export const ENV_PUBLIC_PATH = `/@vite/env`
43// eslint-disable-next-line node/no-missing-require
44export const CLIENT_ENTRY = require.resolve('vite/dist/client/client.mjs')
45// eslint-disable-next-line node/no-missing-require
46export const ENV_ENTRY = require.resolve('vite/dist/client/env.mjs')
47export const CLIENT_DIR = path.dirname(CLIENT_ENTRY)
48
49export const KNOWN_ASSET_TYPES = [
50 // images
51 'png',
52 'jpe?g',
53 'gif',
54 'svg',
55 'ico',
56 'webp',
57 'avif',
58
59 // media
60 'mp4',
61 'webm',
62 'ogg',
63 'mp3',
64 'wav',
65 'flac',
66 'aac',
67
68 // fonts
69 'woff2?',
70 'eot',
71 'ttf',
72 'otf',
73
74 // other
75 'wasm'
76]
77
78export const DEFAULT_ASSETS_RE = new RegExp(
79 `\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`
80)
81
82export const DEP_VERSION_RE = /[\?&](v=[\w\.-]+)\b/