mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
13
node_modules/vite/dist/node/build/buildPluginAsset.d.ts
generated
vendored
Normal file
13
node_modules/vite/dist/node/build/buildPluginAsset.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/// <reference types="node" />
|
||||
import { Plugin, OutputBundle } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
interface AssetCacheEntry {
|
||||
content?: Buffer;
|
||||
fileName?: string;
|
||||
url: string | undefined;
|
||||
}
|
||||
export declare const injectAssetRe: RegExp;
|
||||
export declare const resolveAsset: (id: string, root: string, publicBase: string, assetsDir: string, inlineLimit: number) => Promise<AssetCacheEntry>;
|
||||
export declare const registerAssets: (assets: Map<string, Buffer>, bundle: OutputBundle) => void;
|
||||
export declare const createBuildAssetPlugin: (root: string, resolver: InternalResolver, publicBase: string, assetsDir: string, inlineLimit: number) => Plugin;
|
||||
export {};
|
||||
106
node_modules/vite/dist/node/build/buildPluginAsset.js
generated
vendored
Normal file
106
node_modules/vite/dist/node/build/buildPluginAsset.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildAssetPlugin = exports.registerAssets = exports.resolveAsset = exports.injectAssetRe = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const utils_1 = require("../utils");
|
||||
const slash_1 = __importDefault(require("slash"));
|
||||
const mime_types_1 = __importDefault(require("mime-types"));
|
||||
const debug = require('debug')('vite:build:asset');
|
||||
const assetResolveCache = new Map();
|
||||
const publicDirRE = /^public(\/|\\)/;
|
||||
exports.injectAssetRe = /import.meta.ROLLUP_FILE_URL_(\w+)/;
|
||||
exports.resolveAsset = async (id, root, publicBase, assetsDir, inlineLimit) => {
|
||||
id = utils_1.cleanUrl(id);
|
||||
const cached = assetResolveCache.get(id);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
let resolved;
|
||||
const relativePath = path_1.default.relative(root, id);
|
||||
if (!fs_extra_1.default.existsSync(id)) {
|
||||
// try resolving from public dir
|
||||
const publicDirPath = path_1.default.join(root, 'public', relativePath);
|
||||
if (fs_extra_1.default.existsSync(publicDirPath)) {
|
||||
// file is resolved from public dir, it will be copied verbatim so no
|
||||
// need to read content here.
|
||||
resolved = {
|
||||
url: publicBase + slash_1.default(relativePath)
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!resolved) {
|
||||
if (publicDirRE.test(relativePath)) {
|
||||
resolved = {
|
||||
url: publicBase + slash_1.default(relativePath.replace(publicDirRE, ''))
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!resolved) {
|
||||
let url;
|
||||
let content = await fs_extra_1.default.readFile(id);
|
||||
if (!id.endsWith(`.svg`) && content.length < Number(inlineLimit)) {
|
||||
url = `data:${mime_types_1.default.lookup(id)};base64,${content.toString('base64')}`;
|
||||
content = undefined;
|
||||
}
|
||||
resolved = {
|
||||
content,
|
||||
fileName: path_1.default.basename(id),
|
||||
url
|
||||
};
|
||||
}
|
||||
assetResolveCache.set(id, resolved);
|
||||
return resolved;
|
||||
};
|
||||
exports.registerAssets = (assets, bundle) => {
|
||||
for (const [fileName, source] of assets) {
|
||||
bundle[fileName] = {
|
||||
name: fileName,
|
||||
isAsset: true,
|
||||
type: 'asset',
|
||||
fileName,
|
||||
source
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.createBuildAssetPlugin = (root, resolver, publicBase, assetsDir, inlineLimit) => {
|
||||
const handleToIdMap = new Map();
|
||||
return {
|
||||
name: 'vite:asset',
|
||||
async load(id) {
|
||||
if (resolver.isAssetRequest(id)) {
|
||||
let { fileName, content, url } = await exports.resolveAsset(id, root, publicBase, assetsDir, inlineLimit);
|
||||
if (!url && fileName && content) {
|
||||
const fileHandle = this.emitFile({
|
||||
name: fileName,
|
||||
type: 'asset',
|
||||
source: content
|
||||
});
|
||||
url = 'import.meta.ROLLUP_FILE_URL_' + fileHandle;
|
||||
handleToIdMap.set(fileHandle, id);
|
||||
}
|
||||
else if (url && url.startsWith(`data:`)) {
|
||||
debug(`${id} -> base64 inlined`);
|
||||
}
|
||||
return `export default ${JSON.stringify(url)}`;
|
||||
}
|
||||
},
|
||||
async renderChunk(code) {
|
||||
let match;
|
||||
while ((match = exports.injectAssetRe.exec(code))) {
|
||||
const fileHandle = match[1];
|
||||
const outputFilepath = publicBase + slash_1.default(path_1.default.join(assetsDir, this.getFileName(fileHandle)));
|
||||
code = code.replace(match[0], outputFilepath);
|
||||
const originalId = handleToIdMap.get(fileHandle);
|
||||
if (originalId) {
|
||||
debug(`${originalId} -> ${outputFilepath}`);
|
||||
}
|
||||
}
|
||||
return { code, map: null };
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginAsset.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginAsset.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginAsset.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildPluginAsset.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginAsset.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,wDAAyB;AAEzB,oCAAmC;AACnC,kDAAyB;AACzB,4DAA6B;AAG7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAQlD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA2B,CAAA;AAC5D,MAAM,WAAW,GAAG,gBAAgB,CAAA;AACvB,QAAA,aAAa,GAAG,mCAAmC,CAAA;AAEnD,QAAA,YAAY,GAAG,KAAK,EAC/B,EAAU,EACV,IAAY,EACZ,UAAkB,EAClB,SAAiB,EACjB,WAAm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,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;iBAClC;qBAAM,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;oBACzC,KAAK,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAA;iBACjC;gBACD,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAA;aAC/C;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,IAAI;YACpB,IAAI,KAAK,CAAA;YACT,OAAO,CAAC,KAAK,GAAG,qBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;gBACzC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;gBAC3B,MAAM,cAAc,GAClB,UAAU,GAAG,eAAK,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;gBACxE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;gBAC7C,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;gBAChD,IAAI,UAAU,EAAE;oBACd,KAAK,CAAC,GAAG,UAAU,OAAO,cAAc,EAAE,CAAC,CAAA;iBAC5C;aACF;YACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;QAC5B,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
16
node_modules/vite/dist/node/build/buildPluginCss.d.ts
generated
vendored
Normal file
16
node_modules/vite/dist/node/build/buildPluginCss.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Plugin } from 'rollup';
|
||||
import { BuildConfig } from '../config';
|
||||
import { SFCAsyncStyleCompileOptions } from '@vue/compiler-sfc';
|
||||
import { CssPreprocessOptions } from '../config';
|
||||
interface BuildCssOption {
|
||||
root: string;
|
||||
publicBase: string;
|
||||
assetsDir: string;
|
||||
minify?: BuildConfig['minify'];
|
||||
inlineLimit?: number;
|
||||
cssCodeSplit?: boolean;
|
||||
preprocessOptions?: CssPreprocessOptions;
|
||||
modulesOptions?: SFCAsyncStyleCompileOptions['modulesOptions'];
|
||||
}
|
||||
export declare const createBuildCssPlugin: ({ root, publicBase, assetsDir, minify, inlineLimit, cssCodeSplit, preprocessOptions, modulesOptions }: BuildCssOption) => Plugin;
|
||||
export {};
|
||||
157
node_modules/vite/dist/node/build/buildPluginCss.js
generated
vendored
Normal file
157
node_modules/vite/dist/node/build/buildPluginCss.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildCssPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const slash_1 = __importDefault(require("slash"));
|
||||
const debug = require('debug')('vite:build:css');
|
||||
const cssInjectionMarker = `__VITE_CSS__`;
|
||||
const cssInjectionRE = /__VITE_CSS__\(\)/g;
|
||||
exports.createBuildCssPlugin = ({ root, publicBase, assetsDir, minify = false, inlineLimit = 0, cssCodeSplit = true, preprocessOptions, modulesOptions = {} }) => {
|
||||
const styles = new Map();
|
||||
let staticCss = '';
|
||||
return {
|
||||
name: 'vite:css',
|
||||
async transform(css, id) {
|
||||
if (cssUtils_1.isCSSRequest(id)) {
|
||||
// if this is a Vue SFC style request, it's already processed by
|
||||
// rollup-plugin-vue and we just need to rewrite URLs + collect it
|
||||
const isVueStyle = /\?vue&type=style/.test(id);
|
||||
const preprocessLang = (id.match(cssUtils_1.cssPreprocessLangRE) ||
|
||||
[])[1];
|
||||
const result = isVueStyle
|
||||
? css
|
||||
: await cssUtils_1.compileCss(root, id, {
|
||||
id: '',
|
||||
source: css,
|
||||
filename: id,
|
||||
scoped: false,
|
||||
modules: cssUtils_1.cssModuleRE.test(id),
|
||||
preprocessLang,
|
||||
preprocessOptions,
|
||||
modulesOptions
|
||||
}, true);
|
||||
let modules;
|
||||
if (typeof result === 'string') {
|
||||
css = result;
|
||||
}
|
||||
else {
|
||||
if (result.errors.length) {
|
||||
console.error(`[vite] error applying css transforms: `);
|
||||
result.errors.forEach(console.error);
|
||||
}
|
||||
css = result.code;
|
||||
modules = result.modules;
|
||||
}
|
||||
// process url() - register referenced files as assets
|
||||
// and rewrite the url to the resolved public path
|
||||
if (cssUtils_1.urlRE.test(css)) {
|
||||
const fileDir = path_1.default.dirname(id);
|
||||
css = await cssUtils_1.rewriteCssUrls(css, async (rawUrl) => {
|
||||
const file = path_1.default.posix.isAbsolute(rawUrl)
|
||||
? path_1.default.join(root, rawUrl)
|
||||
: path_1.default.join(fileDir, rawUrl);
|
||||
let { fileName, content, url } = await buildPluginAsset_1.resolveAsset(file, root, publicBase, assetsDir, inlineLimit);
|
||||
if (!url && fileName && content) {
|
||||
url =
|
||||
'import.meta.ROLLUP_FILE_URL_' +
|
||||
this.emitFile({
|
||||
name: fileName,
|
||||
type: 'asset',
|
||||
source: content
|
||||
});
|
||||
}
|
||||
debug(`url(${rawUrl}) -> ${url.startsWith('data:') ? `base64 inlined` : `${file}`}`);
|
||||
return url;
|
||||
});
|
||||
}
|
||||
styles.set(id, css);
|
||||
return {
|
||||
code: modules
|
||||
? pluginutils_1.dataToEsm(modules, { namedExports: true })
|
||||
: (cssCodeSplit
|
||||
? // If code-splitting CSS, inject a fake marker to avoid the module
|
||||
// from being tree-shaken. This preserves the .css file as a
|
||||
// module in the chunk's metadata so that we can retrieve them in
|
||||
// renderChunk.
|
||||
`${cssInjectionMarker}()\n`
|
||||
: ``) + `export default ${JSON.stringify(css)}`,
|
||||
map: null,
|
||||
// #795 css always has side effect
|
||||
moduleSideEffects: true
|
||||
};
|
||||
}
|
||||
},
|
||||
async renderChunk(code, chunk) {
|
||||
let chunkCSS = '';
|
||||
for (const id in chunk.modules) {
|
||||
if (styles.has(id)) {
|
||||
chunkCSS += styles.get(id);
|
||||
}
|
||||
}
|
||||
let match;
|
||||
while ((match = buildPluginAsset_1.injectAssetRe.exec(chunkCSS))) {
|
||||
const outputFilepath = publicBase + slash_1.default(path_1.default.join(assetsDir, this.getFileName(match[1])));
|
||||
chunkCSS = chunkCSS.replace(match[0], outputFilepath);
|
||||
}
|
||||
if (cssCodeSplit) {
|
||||
code = code.replace(cssInjectionRE, '');
|
||||
// for each dynamic entry chunk, collect its css and inline it as JS
|
||||
// strings.
|
||||
if (chunk.isDynamicEntry && chunkCSS) {
|
||||
chunkCSS = minifyCSS(chunkCSS);
|
||||
code =
|
||||
`let ${cssInjectionMarker} = document.createElement('style');` +
|
||||
`${cssInjectionMarker}.innerHTML = ${JSON.stringify(chunkCSS)};` +
|
||||
`document.head.appendChild(${cssInjectionMarker});` +
|
||||
code;
|
||||
}
|
||||
else {
|
||||
staticCss += chunkCSS;
|
||||
}
|
||||
return {
|
||||
code,
|
||||
map: null
|
||||
};
|
||||
}
|
||||
else {
|
||||
staticCss += chunkCSS;
|
||||
return null;
|
||||
}
|
||||
},
|
||||
async generateBundle(_options, bundle) {
|
||||
// minify css
|
||||
if (minify && staticCss) {
|
||||
staticCss = minifyCSS(staticCss);
|
||||
}
|
||||
if (staticCss) {
|
||||
this.emitFile({
|
||||
name: 'style.css',
|
||||
type: 'asset',
|
||||
source: staticCss
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
let CleanCSS;
|
||||
function minifyCSS(css) {
|
||||
CleanCSS = CleanCSS || require('clean-css');
|
||||
const res = new CleanCSS({ level: 2, rebase: false }).minify(css);
|
||||
if (res.errors && res.errors.length) {
|
||||
console.error(chalk_1.default.red(`[vite] error when minifying css:`));
|
||||
console.error(res.errors);
|
||||
}
|
||||
if (res.warnings && res.warnings.length) {
|
||||
console.error(chalk_1.default.yellow(`[vite] warnings when minifying css:`));
|
||||
console.error(res.warnings);
|
||||
}
|
||||
return res.styles;
|
||||
}
|
||||
//# sourceMappingURL=buildPluginCss.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginCss.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginCss.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildPluginCss.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginCss.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEvB,yDAAgE;AAEhE,gDAO0B;AAK1B,kDAAyB;AAEzB,qDAA+C;AAC/C,kDAAyB;AAEzB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;AAEhD,MAAM,kBAAkB,GAAG,cAAc,CAAA;AACzC,MAAM,cAAc,GAAG,mBAAmB,CAAA;AAa7B,QAAA,oBAAoB,GAAG,CAAC,EACnC,IAAI,EACJ,UAAU,EACV,SAAS,EACT,MAAM,GAAG,KAAK,EACd,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,IAAI,EACnB,iBAAiB,EACjB,cAAc,GAAG,EAAE,EACJ,EAAU,EAAE;IAC3B,MAAM,MAAM,GAAwB,IAAI,GAAG,EAAE,CAAA;IAC7C,IAAI,SAAS,GAAG,EAAE,CAAA;IAElB,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,KAAK,CAAC,SAAS,CAAC,GAAW,EAAE,EAAU;YACrC,IAAI,uBAAY,CAAC,EAAE,CAAC,EAAE;gBACpB,gEAAgE;gBAChE,kEAAkE;gBAClE,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAC9C,MAAM,cAAc,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC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AAE;gBACb,IAAI,CAAC,QAAQ,CAAC;oBACZ,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,OAAO;oBACb,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAA;aACH;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED,IAAI,QAAa,CAAA;AAEjB,SAAS,SAAS,CAAC,GAAW;IAC5B,QAAQ,GAAG,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAEjE,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;QACnC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC,CAAA;QAC5D,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;KAC1B;IAED,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE;QACvC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAA;QAClE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;KAC5B;IAED,OAAO,GAAG,CAAC,MAAM,CAAA;AACnB,CAAC"}
|
||||
4
node_modules/vite/dist/node/build/buildPluginEsbuild.d.ts
generated
vendored
Normal file
4
node_modules/vite/dist/node/build/buildPluginEsbuild.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Plugin } from 'rollup';
|
||||
import { SharedConfig } from '../config';
|
||||
export declare const createEsbuildPlugin: (jsx?: SharedConfig['jsx']) => Promise<Plugin>;
|
||||
export declare const createEsbuildRenderChunkPlugin: (target: string, minify: boolean) => Plugin;
|
||||
45
node_modules/vite/dist/node/build/buildPluginEsbuild.js
generated
vendored
Normal file
45
node_modules/vite/dist/node/build/buildPluginEsbuild.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createEsbuildRenderChunkPlugin = exports.createEsbuildPlugin = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const esbuildService_1 = require("../esbuildService");
|
||||
exports.createEsbuildPlugin = async (jsx = 'vue') => {
|
||||
const jsxConfig = esbuildService_1.resolveJsxOptions(jsx);
|
||||
return {
|
||||
name: 'vite:esbuild',
|
||||
resolveId(id) {
|
||||
if (id === esbuildService_1.vueJsxPublicPath) {
|
||||
return esbuildService_1.vueJsxPublicPath;
|
||||
}
|
||||
},
|
||||
load(id) {
|
||||
if (id === esbuildService_1.vueJsxPublicPath) {
|
||||
return fs_extra_1.default.readFileSync(esbuildService_1.vueJsxFilePath, 'utf-8');
|
||||
}
|
||||
},
|
||||
async transform(code, id) {
|
||||
const isVueTs = /\.vue\?/.test(id) && id.endsWith('lang.ts');
|
||||
if (esbuildService_1.tjsxRE.test(id) || isVueTs) {
|
||||
return esbuildService_1.transform(code, id, {
|
||||
...jsxConfig,
|
||||
...(isVueTs ? { loader: 'ts' } : null)
|
||||
}, jsx);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
exports.createEsbuildRenderChunkPlugin = (target, minify) => {
|
||||
return {
|
||||
name: 'vite:esbuild-transpile',
|
||||
async renderChunk(code, chunk) {
|
||||
return esbuildService_1.transform(code, chunk.fileName, {
|
||||
target,
|
||||
minify
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginEsbuild.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginEsbuild.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginEsbuild.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildPluginEsbuild.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginEsbuild.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAyB;AAEzB,sDAM0B;AAGb,QAAA,mBAAmB,GAAG,KAAK,EACtC,MAA2B,KAAK,EACf,EAAE;IACnB,MAAM,SAAS,GAAG,kCAAiB,CAAC,GAAG,CAAC,CAAA;IAExC,OAAO;QACL,IAAI,EAAE,cAAc;QAEpB,SAAS,CAAC,EAAE;YACV,IAAI,EAAE,KAAK,iCAAgB,EAAE;gBAC3B,OAAO,iCAAgB,CAAA;aACxB;QACH,CAAC;QAED,IAAI,CAAC,EAAE;YACL,IAAI,EAAE,KAAK,iCAAgB,EAAE;gBAC3B,OAAO,kBAAE,CAAC,YAAY,CAAC,+BAAc,EAAE,OAAO,CAAC,CAAA;aAChD;QACH,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE;YACtB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;YAC5D,IAAI,uBAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,OAAO,EAAE;gBAC9B,OAAO,0BAAS,CACd,IAAI,EACJ,EAAE,EACF;oBACE,GAAG,SAAS;oBACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBACvC,EACD,GAAG,CACJ,CAAA;aACF;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAEY,QAAA,8BAA8B,GAAG,CAC5C,MAAc,EACd,MAAe,EACP,EAAE;IACV,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK;YAC3B,OAAO,0BAAS,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE;gBACrC,MAAM;gBACN,MAAM;aACP,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
10
node_modules/vite/dist/node/build/buildPluginHtml.d.ts
generated
vendored
Normal file
10
node_modules/vite/dist/node/build/buildPluginHtml.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Plugin, OutputChunk, RollupOutput } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
import { UserConfig } from '../config';
|
||||
export declare const createBuildHtmlPlugin: (root: string, indexPath: string, publicBasePath: string, assetsDir: string, inlineLimit: number, resolver: InternalResolver, shouldPreload: ((chunk: OutputChunk) => boolean) | null, config: UserConfig) => Promise<{
|
||||
renderIndex: () => string;
|
||||
htmlPlugin: null;
|
||||
} | {
|
||||
renderIndex: (bundleOutput: RollupOutput['output']) => Promise<string>;
|
||||
htmlPlugin: Plugin;
|
||||
}>;
|
||||
181
node_modules/vite/dist/node/build/buildPluginHtml.js
generated
vendored
Normal file
181
node_modules/vite/dist/node/build/buildPluginHtml.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildHtmlPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const magic_string_1 = __importDefault(require("magic-string"));
|
||||
const utils_1 = require("../utils");
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
exports.createBuildHtmlPlugin = async (root, indexPath, publicBasePath, assetsDir, inlineLimit, resolver, shouldPreload, config) => {
|
||||
if (!fs_extra_1.default.existsSync(indexPath)) {
|
||||
return {
|
||||
renderIndex: () => '',
|
||||
htmlPlugin: null
|
||||
};
|
||||
}
|
||||
const rawHtml = await fs_extra_1.default.readFile(indexPath, 'utf-8');
|
||||
const preprocessedHtml = await utils_1.transformIndexHtml(rawHtml, config.indexHtmlTransforms, 'pre', true);
|
||||
const assets = new Map();
|
||||
let { html: processedHtml, js } = await compileHtml(root, preprocessedHtml, publicBasePath, assetsDir, inlineLimit, resolver, assets);
|
||||
const htmlPlugin = {
|
||||
name: 'vite:html',
|
||||
async load(id) {
|
||||
if (id === indexPath) {
|
||||
return js;
|
||||
}
|
||||
},
|
||||
generateBundle(_options, bundle) {
|
||||
buildPluginAsset_1.registerAssets(assets, bundle);
|
||||
}
|
||||
};
|
||||
const injectCSS = (html, filename) => {
|
||||
const tag = `<link rel="stylesheet" href="${publicBasePath}${path_1.default.posix.join(assetsDir, filename)}">`;
|
||||
if (/<\/head>/.test(html)) {
|
||||
return html.replace(/<\/head>/, `${tag}\n</head>`);
|
||||
}
|
||||
else {
|
||||
return tag + '\n' + html;
|
||||
}
|
||||
};
|
||||
const injectScript = (html, filename) => {
|
||||
filename = utils_1.isExternalUrl(filename)
|
||||
? filename
|
||||
: `${publicBasePath}${path_1.default.posix.join(assetsDir, filename)}`;
|
||||
const tag = `<script type="module" src="${filename}"></script>`;
|
||||
if (/<\/head>/.test(html)) {
|
||||
return html.replace(/<\/head>/, `${tag}\n</head>`);
|
||||
}
|
||||
else {
|
||||
return html + '\n' + tag;
|
||||
}
|
||||
};
|
||||
const injectPreload = (html, filename) => {
|
||||
filename = utils_1.isExternalUrl(filename)
|
||||
? filename
|
||||
: `${publicBasePath}${path_1.default.posix.join(assetsDir, filename)}`;
|
||||
const tag = `<link rel="modulepreload" href="${filename}" />`;
|
||||
if (/<\/head>/.test(html)) {
|
||||
return html.replace(/<\/head>/, `${tag}\n</head>`);
|
||||
}
|
||||
else {
|
||||
return tag + '\n' + html;
|
||||
}
|
||||
};
|
||||
const renderIndex = async (bundleOutput) => {
|
||||
let result = processedHtml;
|
||||
for (const chunk of bundleOutput) {
|
||||
if (chunk.type === 'chunk') {
|
||||
if (chunk.isEntry) {
|
||||
// js entry chunk
|
||||
result = injectScript(result, chunk.fileName);
|
||||
}
|
||||
else if (shouldPreload && shouldPreload(chunk)) {
|
||||
// async preloaded chunk
|
||||
result = injectPreload(result, chunk.fileName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// imported css chunks
|
||||
if (chunk.fileName.endsWith('.css') &&
|
||||
chunk.source &&
|
||||
!assets.has(chunk.fileName)) {
|
||||
result = injectCSS(result, chunk.fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return await utils_1.transformIndexHtml(result, config.indexHtmlTransforms, 'post', true);
|
||||
};
|
||||
return {
|
||||
renderIndex,
|
||||
htmlPlugin
|
||||
};
|
||||
};
|
||||
// this extends the config in @vue/compiler-sfc with <link href>
|
||||
const assetAttrsConfig = {
|
||||
link: ['href'],
|
||||
video: ['src', 'poster'],
|
||||
source: ['src'],
|
||||
img: ['src'],
|
||||
image: ['xlink:href', 'href'],
|
||||
use: ['xlink:href', 'href']
|
||||
};
|
||||
// compile index.html to a JS module, importing referenced assets
|
||||
// and scripts
|
||||
const compileHtml = async (root, html, publicBasePath, assetsDir, inlineLimit, resolver, assets) => {
|
||||
const { parse, transform } = require('@vue/compiler-dom');
|
||||
// @vue/compiler-core doesn't like lowercase doctypes
|
||||
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
||||
const ast = parse(html);
|
||||
let js = '';
|
||||
const s = new magic_string_1.default(html);
|
||||
const assetUrls = [];
|
||||
const viteHtmlTransform = (node) => {
|
||||
if (node.type === 1 /* ELEMENT */) {
|
||||
if (node.tag === 'script') {
|
||||
let shouldRemove = false;
|
||||
const srcAttr = node.props.find((p) => p.type === 6 /* ATTRIBUTE */ && p.name === 'src');
|
||||
const typeAttr = node.props.find((p) => p.type === 6 /* ATTRIBUTE */ && p.name === 'type');
|
||||
const isJsModule = typeAttr && typeAttr.value && typeAttr.value.content === 'module';
|
||||
if (isJsModule) {
|
||||
if (srcAttr && srcAttr.value) {
|
||||
if (!utils_1.isExternalUrl(srcAttr.value.content)) {
|
||||
// <script type="module" src="..."/>
|
||||
// add it as an import
|
||||
js += `\nimport ${JSON.stringify(srcAttr.value.content)}`;
|
||||
shouldRemove = true;
|
||||
}
|
||||
}
|
||||
else if (node.children.length) {
|
||||
// <script type="module">...</script>
|
||||
// add its content
|
||||
// TODO: if there are multiple inline module scripts on the page,
|
||||
// they should technically be turned into separate modules, but
|
||||
// it's hard to imagine any reason for anyone to do that.
|
||||
js += `\n` + node.children[0].content.trim() + `\n`;
|
||||
shouldRemove = true;
|
||||
}
|
||||
}
|
||||
if (shouldRemove) {
|
||||
// remove the script tag from the html. we are going to inject new
|
||||
// ones in the end.
|
||||
s.remove(node.loc.start.offset, node.loc.end.offset);
|
||||
}
|
||||
}
|
||||
// For asset references in index.html, also generate an import
|
||||
// statement for each - this will be handled by the asset plugin
|
||||
const assetAttrs = assetAttrsConfig[node.tag];
|
||||
if (assetAttrs) {
|
||||
for (const p of node.props) {
|
||||
if (p.type === 6 /* ATTRIBUTE */ &&
|
||||
p.value &&
|
||||
assetAttrs.includes(p.name) &&
|
||||
!utils_1.isExternalUrl(p.value.content) &&
|
||||
!utils_1.isDataUrl(p.value.content)) {
|
||||
assetUrls.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
transform(ast, {
|
||||
nodeTransforms: [viteHtmlTransform]
|
||||
});
|
||||
// for each encountered asset url, rewrite original html so that it
|
||||
// references the post-build location.
|
||||
for (const attr of assetUrls) {
|
||||
const value = attr.value;
|
||||
const { fileName, content, url } = await buildPluginAsset_1.resolveAsset(resolver.requestToFile(value.content), root, publicBasePath, assetsDir, utils_1.cleanUrl(value.content).endsWith('.css') ? 0 : inlineLimit);
|
||||
s.overwrite(value.loc.start.offset, value.loc.end.offset, `"${url}"`);
|
||||
if (fileName && content) {
|
||||
assets.set(fileName, content);
|
||||
}
|
||||
}
|
||||
return {
|
||||
html: s.toString(),
|
||||
js
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginHtml.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginHtml.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginHtml.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/vite/dist/node/build/buildPluginManifest.d.ts
generated
vendored
Normal file
2
node_modules/vite/dist/node/build/buildPluginManifest.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Plugin } from 'rollup';
|
||||
export declare const createBuildManifestPlugin: () => Plugin;
|
||||
26
node_modules/vite/dist/node/build/buildPluginManifest.js
generated
vendored
Normal file
26
node_modules/vite/dist/node/build/buildPluginManifest.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildManifestPlugin = void 0;
|
||||
exports.createBuildManifestPlugin = () => {
|
||||
const manifest = {};
|
||||
return {
|
||||
name: 'vite:manifest',
|
||||
generateBundle(_options, bundle) {
|
||||
for (const name in bundle) {
|
||||
const chunk = bundle[name];
|
||||
if (chunk.type === 'chunk') {
|
||||
manifest[chunk.name + '.js'] = chunk.fileName;
|
||||
}
|
||||
else {
|
||||
manifest[chunk.name] = chunk.fileName;
|
||||
}
|
||||
}
|
||||
this.emitFile({
|
||||
fileName: 'manifest.json',
|
||||
type: 'asset',
|
||||
source: JSON.stringify(manifest, null, 2)
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginManifest.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginManifest.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginManifest.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildPluginManifest.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginManifest.ts"],"names":[],"mappings":";;;AAEa,QAAA,yBAAyB,GAAG,GAAW,EAAE;IACpD,MAAM,QAAQ,GAA2B,EAAE,CAAA;IAC3C,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,cAAc,CAAC,QAAQ,EAAE,MAAM;YAC7B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;gBACzB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;oBAC1B,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAA;iBAC9C;qBAAM;oBACL,QAAQ,CAAC,KAAK,CAAC,IAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAA;iBACvC;aACF;YACD,IAAI,CAAC,QAAQ,CAAC;gBACZ,QAAQ,EAAE,eAAe;gBACzB,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;aAC1C,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
2
node_modules/vite/dist/node/build/buildPluginReplace.d.ts
generated
vendored
Normal file
2
node_modules/vite/dist/node/build/buildPluginReplace.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Plugin } from 'rollup';
|
||||
export declare const createReplacePlugin: (test: (id: string) => boolean, replacements: Record<string, any>, sourcemap: boolean) => Plugin;
|
||||
42
node_modules/vite/dist/node/build/buildPluginReplace.js
generated
vendored
Normal file
42
node_modules/vite/dist/node/build/buildPluginReplace.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createReplacePlugin = void 0;
|
||||
const magic_string_1 = __importDefault(require("magic-string"));
|
||||
exports.createReplacePlugin = (test, replacements, sourcemap) => {
|
||||
const pattern = new RegExp('\\b(' +
|
||||
Object.keys(replacements)
|
||||
.map((str) => {
|
||||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
||||
})
|
||||
.join('|') +
|
||||
')\\b', 'g');
|
||||
return {
|
||||
name: 'vite:replace',
|
||||
transform(code, id) {
|
||||
if (test(id)) {
|
||||
const s = new magic_string_1.default(code);
|
||||
let hasReplaced = false;
|
||||
let match;
|
||||
while ((match = pattern.exec(code))) {
|
||||
hasReplaced = true;
|
||||
const start = match.index;
|
||||
const end = start + match[0].length;
|
||||
const replacement = '' + replacements[match[1]];
|
||||
s.overwrite(start, end, replacement);
|
||||
}
|
||||
if (!hasReplaced) {
|
||||
return null;
|
||||
}
|
||||
const result = { code: s.toString() };
|
||||
if (sourcemap) {
|
||||
result.map = s.generateMap({ hires: true });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginReplace.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginReplace.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginReplace.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildPluginReplace.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginReplace.ts"],"names":[],"mappings":";;;;;;AACA,gEAAsC;AAEzB,QAAA,mBAAmB,GAAG,CACjC,IAA6B,EAC7B,YAAiC,EACjC,SAAkB,EACV,EAAE;IACV,MAAM,OAAO,GAAG,IAAI,MAAM,CACxB,MAAM;QACJ,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;aACtB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,OAAO,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAA;QACrD,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC;QACZ,MAAM,EACR,GAAG,CACJ,CAAA;IAED,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,SAAS,CAAC,IAAI,EAAE,EAAE;YAChB,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE;gBACZ,MAAM,CAAC,GAAG,IAAI,sBAAW,CAAC,IAAI,CAAC,CAAA;gBAC/B,IAAI,WAAW,GAAG,KAAK,CAAA;gBACvB,IAAI,KAAK,CAAA;gBAET,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;oBACnC,WAAW,GAAG,IAAI,CAAA;oBAClB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;oBACzB,MAAM,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;oBACnC,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;oBAC/C,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;iBACrC;gBAED,IAAI,CAAC,WAAW,EAAE;oBAChB,OAAO,IAAI,CAAA;iBACZ;gBAED,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;gBACtD,IAAI,SAAS,EAAE;oBACb,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;iBAC5C;gBACD,OAAO,MAAM,CAAA;aACd;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
3
node_modules/vite/dist/node/build/buildPluginResolve.d.ts
generated
vendored
Normal file
3
node_modules/vite/dist/node/build/buildPluginResolve.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Plugin } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
export declare const createBuildResolvePlugin: (root: string, resolver: InternalResolver) => Plugin;
|
||||
41
node_modules/vite/dist/node/build/buildPluginResolve.js
generated
vendored
Normal file
41
node_modules/vite/dist/node/build/buildPluginResolve.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildResolvePlugin = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const resolveVue_1 = require("../utils/resolveVue");
|
||||
const utils_1 = require("../utils");
|
||||
const debug = require('debug')('vite:build:resolve');
|
||||
exports.createBuildResolvePlugin = (root, resolver) => {
|
||||
return {
|
||||
name: 'vite:resolve',
|
||||
async resolveId(id, importer) {
|
||||
const original = id;
|
||||
id = resolver.alias(id) || id;
|
||||
if (id === 'vue' || id.startsWith('@vue/')) {
|
||||
const vuePaths = resolveVue_1.resolveVue(root);
|
||||
if (id in vuePaths) {
|
||||
return vuePaths[id];
|
||||
}
|
||||
}
|
||||
if (utils_1.isExternalUrl(id)) {
|
||||
return { id, external: true };
|
||||
}
|
||||
if (id.startsWith('/') && !id.startsWith(root)) {
|
||||
const resolved = resolver.requestToFile(id);
|
||||
if (fs_extra_1.default.existsSync(resolved)) {
|
||||
debug(id, `-->`, resolved);
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
// fallback to node-resolve because alias
|
||||
if (id !== original) {
|
||||
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
||||
return resolved || { id };
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginResolve.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginResolve.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginResolve.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildPluginResolve.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginResolve.ts"],"names":[],"mappings":";;;;;;AACA,wDAAyB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AAO,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAA;aAC1B;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
2
node_modules/vite/dist/node/build/buildPluginWasm.d.ts
generated
vendored
Normal file
2
node_modules/vite/dist/node/build/buildPluginWasm.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Plugin } from 'rollup';
|
||||
export declare const createBuildWasmPlugin: (root: string, publicBase: string, assetsDir: string, inlineLimit: number) => Plugin;
|
||||
65
node_modules/vite/dist/node/build/buildPluginWasm.js
generated
vendored
Normal file
65
node_modules/vite/dist/node/build/buildPluginWasm.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildWasmPlugin = void 0;
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
const wasmHelperId = 'vite/wasm-helper';
|
||||
const wasmHelper = (opts = {}, url) => {
|
||||
let instance;
|
||||
if (url.startsWith('data:')) {
|
||||
// @ts-ignore
|
||||
const binaryString = atob(url.replace(/^data:.*?base64,/, ''));
|
||||
const bytes = new Uint8Array(binaryString.length);
|
||||
for (let i = 0; i < binaryString.length; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
// @ts-ignore
|
||||
instance = WebAssembly.instantiate(bytes.buffer, opts);
|
||||
}
|
||||
else {
|
||||
// https://github.com/mdn/webassembly-examples/issues/5
|
||||
// WebAssembly.instantiateStreaming requires the server to provide the
|
||||
// correct MIME type for .wasm files, which unfortunately doesn't work for
|
||||
// a lot of static file servers, so we just work around it by getting the
|
||||
// raw buffer.
|
||||
// @ts-ignore
|
||||
instance = fetch(url)
|
||||
// @ts-ignore
|
||||
.then((r) => r.arrayBuffer())
|
||||
// @ts-ignore
|
||||
.then((bytes) => WebAssembly.instantiate(bytes, opts));
|
||||
}
|
||||
return instance.then((i) => i.instance.exports);
|
||||
};
|
||||
const wasmHelperCode = wasmHelper.toString();
|
||||
exports.createBuildWasmPlugin = (root, publicBase, assetsDir, inlineLimit) => {
|
||||
return {
|
||||
name: 'vite:wasm',
|
||||
resolveId(id) {
|
||||
if (id === wasmHelperId) {
|
||||
return id;
|
||||
}
|
||||
},
|
||||
async load(id) {
|
||||
if (id === wasmHelperId) {
|
||||
return `export default ${wasmHelperCode}`;
|
||||
}
|
||||
if (id.endsWith('.wasm')) {
|
||||
let { fileName, content, url } = await buildPluginAsset_1.resolveAsset(id, root, publicBase, assetsDir, inlineLimit);
|
||||
if (!url && fileName && content) {
|
||||
url =
|
||||
'import.meta.ROLLUP_FILE_URL_' +
|
||||
this.emitFile({
|
||||
name: fileName,
|
||||
type: 'asset',
|
||||
source: content
|
||||
});
|
||||
}
|
||||
return `
|
||||
import initWasm from "${wasmHelperId}"
|
||||
export default opts => initWasm(opts, ${JSON.stringify(url)})
|
||||
`;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginWasm.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginWasm.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/buildPluginWasm.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buildPluginWasm.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginWasm.ts"],"names":[],"mappings":";;;AACA,yDAAiD;AAEjD,MAAM,YAAY,GAAG,kBAAkB,CAAA;AAEvC,MAAM,UAAU,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,GAAW,EAAE,EAAE;IAC5C,IAAI,QAAQ,CAAA;IACZ,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3B,aAAa;QACb,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAA;QAC9D,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CA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AQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,+BAAY,CACjD,EAAE,EACF,IAAI,EACJ,UAAU,EACV,SAAS,EACT,WAAW,CACZ,CAAA;gBACD,IAAI,CAAC,GAAG,IAAI,QAAQ,IAAI,OAAO,EAAE;oBAC/B,GAAG;wBACD,8BAA8B;4BAC9B,IAAI,CAAC,QAAQ,CAAC;gCACZ,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,OAAO;gCACb,MAAM,EAAE,OAAO;6BAChB,CAAC,CAAA;iBACL;gBAED,OAAO;wBACS,YAAY;wCACI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;CAC1D,CAAA;aACM;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
39
node_modules/vite/dist/node/build/index.d.ts
generated
vendored
Normal file
39
node_modules/vite/dist/node/build/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Ora } from 'ora';
|
||||
import { Plugin, InputOption, InputOptions, OutputOptions, RollupOutput } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
import { BuildConfig } from '../config';
|
||||
interface Build extends InputOptions {
|
||||
input: InputOption;
|
||||
output: OutputOptions;
|
||||
/** Runs before global post-build hooks. */
|
||||
onResult?: PostBuildHook;
|
||||
}
|
||||
export interface BuildResult {
|
||||
build: Build;
|
||||
html: string;
|
||||
assets: RollupOutput['output'];
|
||||
}
|
||||
/** For adding Rollup builds and mutating the Vite config. */
|
||||
export declare type BuildPlugin = (config: BuildConfig, builds: Build[]) => PostBuildHook | void;
|
||||
/** Returned by `configureBuild` hook to mutate a build's output. */
|
||||
export declare type PostBuildHook = (result: BuildResult) => Promise<void> | void;
|
||||
export declare function onRollupWarning(spinner: Ora | undefined, options: BuildConfig['optimizeDeps']): InputOptions['onwarn'];
|
||||
/**
|
||||
* Creates non-application specific plugins that are shared between the main
|
||||
* app and the dependencies. This is used by the `optimize` command to
|
||||
* pre-bundle dependencies.
|
||||
*/
|
||||
export declare function createBaseRollupPlugins(root: string, resolver: InternalResolver, options: Partial<BuildConfig>): Promise<Plugin[]>;
|
||||
/**
|
||||
* Bundles the app for production.
|
||||
* Returns a Promise containing the build result.
|
||||
*/
|
||||
export declare function build(options: Partial<BuildConfig>): Promise<BuildResult[]>;
|
||||
/**
|
||||
* Bundles the app in SSR mode.
|
||||
* - All Vue dependencies are automatically externalized
|
||||
* - Imports to dependencies are compiled into require() calls
|
||||
* - Templates are compiled with SSR specific optimizations.
|
||||
*/
|
||||
export declare function ssrBuild(options: Partial<BuildConfig>): Promise<BuildResult[]>;
|
||||
export {};
|
||||
530
node_modules/vite/dist/node/build/index.js
generated
vendored
Normal file
530
node_modules/vite/dist/node/build/index.js
generated
vendored
Normal file
@@ -0,0 +1,530 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ssrBuild = exports.build = exports.createBaseRollupPlugins = exports.onRollupWarning = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const p_map_series_1 = __importDefault(require("p-map-series"));
|
||||
const json_1 = require("klona/json");
|
||||
const utils_1 = require("../utils");
|
||||
const resolver_1 = require("../resolver");
|
||||
const buildPluginResolve_1 = require("./buildPluginResolve");
|
||||
const buildPluginHtml_1 = require("./buildPluginHtml");
|
||||
const buildPluginCss_1 = require("./buildPluginCss");
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
const buildPluginEsbuild_1 = require("./buildPluginEsbuild");
|
||||
const buildPluginReplace_1 = require("./buildPluginReplace");
|
||||
const esbuildService_1 = require("../esbuildService");
|
||||
const config_1 = require("../config");
|
||||
const transform_1 = require("../transform");
|
||||
const hash_sum_1 = __importDefault(require("hash-sum"));
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const buildPluginWasm_1 = require("./buildPluginWasm");
|
||||
const buildPluginManifest_1 = require("./buildPluginManifest");
|
||||
const writeColors = {
|
||||
[0 /* JS */]: chalk_1.default.cyan,
|
||||
[1 /* CSS */]: chalk_1.default.magenta,
|
||||
[2 /* ASSET */]: chalk_1.default.green,
|
||||
[3 /* HTML */]: chalk_1.default.blue,
|
||||
[4 /* SOURCE_MAP */]: chalk_1.default.gray
|
||||
};
|
||||
const warningIgnoreList = [`CIRCULAR_DEPENDENCY`, `THIS_IS_UNDEFINED`];
|
||||
const dynamicImportWarningIgnoreList = [
|
||||
`Unsupported expression`,
|
||||
`statically analyzed`
|
||||
];
|
||||
const isBuiltin = require('isbuiltin');
|
||||
function onRollupWarning(spinner, options) {
|
||||
return (warning, warn) => {
|
||||
if (warning.code === 'UNRESOLVED_IMPORT') {
|
||||
let message;
|
||||
const id = warning.source;
|
||||
const importer = warning.importer;
|
||||
if (isBuiltin(id)) {
|
||||
let importingDep;
|
||||
if (importer) {
|
||||
const pkg = JSON.parse(utils_1.lookupFile(importer, ['package.json']) || `{}`);
|
||||
if (pkg.name) {
|
||||
importingDep = pkg.name;
|
||||
}
|
||||
}
|
||||
const allowList = options.allowNodeBuiltins;
|
||||
if (importingDep && allowList && allowList.includes(importingDep)) {
|
||||
return;
|
||||
}
|
||||
const dep = importingDep
|
||||
? `Dependency ${chalk_1.default.yellow(importingDep)}`
|
||||
: `A dependency`;
|
||||
message =
|
||||
`${dep} is attempting to import Node built-in module ${chalk_1.default.yellow(id)}.\n` +
|
||||
`This will not work in a browser environment.\n` +
|
||||
`Imported by: ${chalk_1.default.gray(importer)}`;
|
||||
}
|
||||
else {
|
||||
message =
|
||||
`[vite]: Rollup failed to resolve import "${warning.source}" from "${warning.importer}".\n` +
|
||||
`This is most likely unintended because it can break your application at runtime.\n` +
|
||||
`If you do want to externalize this module explicitly add it to\n` +
|
||||
`\`rollupInputOptions.external\``;
|
||||
}
|
||||
if (spinner) {
|
||||
spinner.stop();
|
||||
}
|
||||
throw new Error(message);
|
||||
}
|
||||
if (warning.plugin === 'rollup-plugin-dynamic-import-variables' &&
|
||||
dynamicImportWarningIgnoreList.some((msg) => warning.message.includes(msg))) {
|
||||
return;
|
||||
}
|
||||
if (!warningIgnoreList.includes(warning.code)) {
|
||||
// ora would swallow the console.warn if we let it keep running
|
||||
// https://github.com/sindresorhus/ora/issues/90
|
||||
if (spinner) {
|
||||
spinner.stop();
|
||||
}
|
||||
warn(warning);
|
||||
if (spinner) {
|
||||
spinner.start();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.onRollupWarning = onRollupWarning;
|
||||
/**
|
||||
* Creates non-application specific plugins that are shared between the main
|
||||
* app and the dependencies. This is used by the `optimize` command to
|
||||
* pre-bundle dependencies.
|
||||
*/
|
||||
async function createBaseRollupPlugins(root, resolver, options) {
|
||||
const { transforms = [], vueCustomBlockTransforms = {}, enableEsbuild = true, enableRollupPluginVue = true } = options;
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
||||
const dynamicImport = require('rollup-plugin-dynamic-import-variables');
|
||||
return [
|
||||
// vite:resolve
|
||||
buildPluginResolve_1.createBuildResolvePlugin(root, resolver),
|
||||
// vite:esbuild
|
||||
enableEsbuild ? await buildPluginEsbuild_1.createEsbuildPlugin(options.jsx) : null,
|
||||
// vue
|
||||
enableRollupPluginVue ? await createVuePlugin(root, options) : null,
|
||||
require('@rollup/plugin-json')({
|
||||
preferConst: true,
|
||||
indent: ' ',
|
||||
compact: false,
|
||||
namedExports: true
|
||||
}),
|
||||
// user transforms
|
||||
...(transforms.length || Object.keys(vueCustomBlockTransforms).length
|
||||
? [transform_1.createBuildJsTransformPlugin(transforms, vueCustomBlockTransforms)]
|
||||
: []),
|
||||
nodeResolve({
|
||||
rootDir: root,
|
||||
extensions: resolver_1.supportedExts,
|
||||
preferBuiltins: false,
|
||||
dedupe: options.rollupDedupe || [],
|
||||
mainFields: resolver_1.mainFields
|
||||
}),
|
||||
require('@rollup/plugin-commonjs')({
|
||||
extensions: ['.js', '.cjs']
|
||||
}),
|
||||
dynamicImport({
|
||||
warnOnError: true,
|
||||
include: [/\.js$/],
|
||||
exclude: [/node_modules/]
|
||||
})
|
||||
].filter(Boolean);
|
||||
}
|
||||
exports.createBaseRollupPlugins = createBaseRollupPlugins;
|
||||
async function createVuePlugin(root, { vueCustomBlockTransforms = {}, rollupPluginVueOptions, cssPreprocessOptions, cssModuleOptions, vueCompilerOptions, vueTransformAssetUrls = {}, vueTemplatePreprocessOptions = {} }) {
|
||||
const { options: postcssOptions, plugins: postcssPlugins } = await cssUtils_1.resolvePostcssOptions(root, true);
|
||||
if (typeof vueTransformAssetUrls === 'object') {
|
||||
vueTransformAssetUrls = {
|
||||
includeAbsolute: true,
|
||||
...vueTransformAssetUrls
|
||||
};
|
||||
}
|
||||
return require('rollup-plugin-vue')({
|
||||
...rollupPluginVueOptions,
|
||||
templatePreprocessOptions: {
|
||||
...vueTemplatePreprocessOptions,
|
||||
pug: {
|
||||
doctype: 'html',
|
||||
...(vueTemplatePreprocessOptions && vueTemplatePreprocessOptions.pug)
|
||||
}
|
||||
},
|
||||
transformAssetUrls: vueTransformAssetUrls,
|
||||
postcssOptions,
|
||||
postcssPlugins,
|
||||
preprocessStyles: true,
|
||||
preprocessOptions: cssPreprocessOptions,
|
||||
preprocessCustomRequire: (id) => require(utils_1.resolveFrom(root, id)),
|
||||
compilerOptions: vueCompilerOptions,
|
||||
cssModulesOptions: {
|
||||
localsConvention: 'camelCase',
|
||||
generateScopedName: (local, filename) => `${local}_${hash_sum_1.default(filename)}`,
|
||||
...cssModuleOptions,
|
||||
...(rollupPluginVueOptions && rollupPluginVueOptions.cssModulesOptions)
|
||||
},
|
||||
customBlocks: Object.keys(vueCustomBlockTransforms)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Clone the given config object and fill it with default values.
|
||||
*/
|
||||
function prepareConfig(config) {
|
||||
const { alias = {}, assetsDir = '_assets', assetsInclude = utils_1.isStaticAsset, assetsInlineLimit = 4096, base = '/', cssCodeSplit = true, cssModuleOptions = {}, cssPreprocessOptions = {}, define = {}, emitAssets = true, emitIndex = true, enableEsbuild = true, enableRollupPluginVue = true, entry = 'index.html', env = {}, esbuildTarget = 'es2020', indexHtmlTransforms = [], jsx = 'vue', minify = true, mode = 'production', optimizeDeps = {}, outDir = 'dist', resolvers = [], rollupDedupe = [], rollupInputOptions = {}, rollupOutputOptions = {}, rollupPluginVueOptions = {}, root = process.cwd(), shouldPreload = null, silent = false, sourcemap = false, terserOptions = {}, transforms = [], vueCompilerOptions = {}, vueCustomBlockTransforms = {}, vueTransformAssetUrls = {}, vueTemplatePreprocessOptions = {}, write = true } = json_1.klona(config);
|
||||
return {
|
||||
...config,
|
||||
alias,
|
||||
assetsDir,
|
||||
assetsInclude,
|
||||
assetsInlineLimit,
|
||||
base,
|
||||
cssCodeSplit,
|
||||
cssModuleOptions,
|
||||
cssPreprocessOptions,
|
||||
define,
|
||||
emitAssets,
|
||||
emitIndex,
|
||||
enableEsbuild,
|
||||
enableRollupPluginVue,
|
||||
entry,
|
||||
env,
|
||||
esbuildTarget,
|
||||
indexHtmlTransforms,
|
||||
jsx,
|
||||
minify,
|
||||
mode,
|
||||
optimizeDeps,
|
||||
outDir,
|
||||
resolvers,
|
||||
rollupDedupe,
|
||||
rollupInputOptions,
|
||||
rollupOutputOptions,
|
||||
rollupPluginVueOptions,
|
||||
root,
|
||||
shouldPreload,
|
||||
silent,
|
||||
sourcemap,
|
||||
terserOptions,
|
||||
transforms,
|
||||
vueCompilerOptions,
|
||||
vueCustomBlockTransforms,
|
||||
vueTransformAssetUrls,
|
||||
vueTemplatePreprocessOptions,
|
||||
write
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Bundles the app for production.
|
||||
* Returns a Promise containing the build result.
|
||||
*/
|
||||
async function build(options) {
|
||||
const builds = [];
|
||||
const config = prepareConfig(options);
|
||||
const postBuildHooks = utils_1.toArray(config.configureBuild)
|
||||
.map((configureBuild) => configureBuild(config, builds))
|
||||
.filter(Boolean);
|
||||
const { root, assetsDir, assetsInlineLimit, emitAssets, minify, silent, sourcemap, shouldPreload, env, mode: configMode, define: userDefineReplacements, write } = config;
|
||||
const isTest = process.env.NODE_ENV === 'test';
|
||||
const resolvedMode = process.env.VITE_ENV || configMode;
|
||||
const start = Date.now();
|
||||
let spinner;
|
||||
const msg = `Building ${configMode} bundle...`;
|
||||
if (!silent) {
|
||||
if (process.env.DEBUG || isTest) {
|
||||
console.log(msg);
|
||||
}
|
||||
else {
|
||||
spinner = require('ora')(msg + '\n').start();
|
||||
}
|
||||
}
|
||||
const outDir = path_1.default.resolve(root, config.outDir);
|
||||
const indexPath = path_1.default.resolve(root, 'index.html');
|
||||
const publicDir = path_1.default.join(root, 'public');
|
||||
const publicBasePath = config.base.replace(/([^/])$/, '$1/'); // ensure ending slash
|
||||
const resolvedAssetsPath = path_1.default.join(outDir, assetsDir);
|
||||
const resolver = resolver_1.createResolver(root, config.resolvers, config.alias, config.assetsInclude);
|
||||
const { htmlPlugin, renderIndex } = await buildPluginHtml_1.createBuildHtmlPlugin(root, indexPath, publicBasePath, assetsDir, assetsInlineLimit, resolver, shouldPreload, options);
|
||||
const basePlugins = await createBaseRollupPlugins(root, resolver, config);
|
||||
// https://github.com/darionco/rollup-plugin-web-worker-loader
|
||||
// configured to support `import Worker from './my-worker?worker'`
|
||||
// this plugin relies on resolveId and must be placed before node-resolve
|
||||
// since the latter somehow swallows ids with query strings since 8.x
|
||||
basePlugins.splice(basePlugins.findIndex((p) => p.name.includes('node-resolve')), 0, require('rollup-plugin-web-worker-loader')({
|
||||
targetPlatform: 'browser',
|
||||
pattern: /(.+)\?worker$/,
|
||||
extensions: resolver_1.supportedExts,
|
||||
sourcemap: false // it's inlined so it bloats the bundle
|
||||
}));
|
||||
// user env variables loaded from .env files.
|
||||
// only those prefixed with VITE_ are exposed.
|
||||
const userClientEnv = {};
|
||||
const userEnvReplacements = {};
|
||||
Object.keys(env).forEach((key) => {
|
||||
if (key.startsWith(`VITE_`)) {
|
||||
userEnvReplacements[`import.meta.env.${key}`] = JSON.stringify(env[key]);
|
||||
userClientEnv[key] = env[key];
|
||||
}
|
||||
});
|
||||
const builtInClientEnv = {
|
||||
BASE_URL: publicBasePath,
|
||||
MODE: configMode,
|
||||
DEV: resolvedMode !== 'production',
|
||||
PROD: resolvedMode === 'production'
|
||||
};
|
||||
const builtInEnvReplacements = {};
|
||||
Object.keys(builtInClientEnv).forEach((key) => {
|
||||
builtInEnvReplacements[`import.meta.env.${key}`] = JSON.stringify(builtInClientEnv[key]);
|
||||
});
|
||||
Object.keys(userDefineReplacements).forEach((key) => {
|
||||
userDefineReplacements[key] = JSON.stringify(userDefineReplacements[key]);
|
||||
});
|
||||
const { pluginsPreBuild = [], plugins = [], pluginsPostBuild = [], pluginsOptimizer, ...rollupInputOptions } = config.rollupInputOptions;
|
||||
builds.unshift({
|
||||
input: config.entry,
|
||||
preserveEntrySignatures: false,
|
||||
treeshake: { moduleSideEffects: 'no-external' },
|
||||
...rollupInputOptions,
|
||||
output: config.rollupOutputOptions,
|
||||
plugins: [
|
||||
...plugins,
|
||||
...pluginsPreBuild,
|
||||
...basePlugins,
|
||||
// vite:html
|
||||
htmlPlugin,
|
||||
// we use a custom replacement plugin because @rollup/plugin-replace
|
||||
// performs replacements twice, once at transform and once at renderChunk
|
||||
// - which makes it impossible to exclude Vue templates from it since
|
||||
// Vue templates are compiled into js and included in chunks.
|
||||
buildPluginReplace_1.createReplacePlugin((id) => !/\?vue&type=template/.test(id) &&
|
||||
// also exclude css and static assets for performance
|
||||
!cssUtils_1.isCSSRequest(id) &&
|
||||
!resolver.isAssetRequest(id), {
|
||||
...config_1.defaultDefines,
|
||||
...userDefineReplacements,
|
||||
...userEnvReplacements,
|
||||
...builtInEnvReplacements,
|
||||
'import.meta.env.': `({}).`,
|
||||
'import.meta.env': JSON.stringify({
|
||||
...userClientEnv,
|
||||
...builtInClientEnv
|
||||
}),
|
||||
'process.env.NODE_ENV': JSON.stringify(resolvedMode),
|
||||
'process.env.': `({}).`,
|
||||
'process.env': JSON.stringify({ NODE_ENV: resolvedMode }),
|
||||
'import.meta.hot': `false`
|
||||
}, !!sourcemap),
|
||||
// vite:css
|
||||
buildPluginCss_1.createBuildCssPlugin({
|
||||
root,
|
||||
publicBase: publicBasePath,
|
||||
assetsDir,
|
||||
minify,
|
||||
inlineLimit: assetsInlineLimit,
|
||||
cssCodeSplit: config.cssCodeSplit,
|
||||
preprocessOptions: config.cssPreprocessOptions,
|
||||
modulesOptions: config.cssModuleOptions
|
||||
}),
|
||||
// vite:wasm
|
||||
buildPluginWasm_1.createBuildWasmPlugin(root, publicBasePath, assetsDir, assetsInlineLimit),
|
||||
// vite:asset
|
||||
buildPluginAsset_1.createBuildAssetPlugin(root, resolver, publicBasePath, assetsDir, assetsInlineLimit),
|
||||
config.enableEsbuild &&
|
||||
buildPluginEsbuild_1.createEsbuildRenderChunkPlugin(config.esbuildTarget, minify === 'esbuild'),
|
||||
// minify with terser
|
||||
// this is the default which has better compression, but slow
|
||||
// the user can opt-in to use esbuild which is much faster but results
|
||||
// in ~8-10% larger file size.
|
||||
minify && minify !== 'esbuild'
|
||||
? require('rollup-plugin-terser').terser(config.terserOptions)
|
||||
: undefined,
|
||||
// #728 user plugins should apply after `@rollup/plugin-commonjs`
|
||||
// #471#issuecomment-683318951 user plugin after internal plugin
|
||||
...pluginsPostBuild,
|
||||
// vite:manifest
|
||||
config.emitManifest ? buildPluginManifest_1.createBuildManifestPlugin() : undefined
|
||||
].filter(Boolean)
|
||||
});
|
||||
// lazy require rollup so that we don't load it when only using the dev server
|
||||
// importing it just for the types
|
||||
const rollup = require('rollup').rollup;
|
||||
// multiple builds are processed sequentially, in case a build
|
||||
// depends on the output of a preceding build.
|
||||
const results = await p_map_series_1.default(builds, async (build, i) => {
|
||||
const { output: outputOptions, onResult, ...inputOptions } = build;
|
||||
let result;
|
||||
let indexHtml;
|
||||
let indexHtmlPath = getIndexHtmlOutputPath(build);
|
||||
const emitIndex = config.emitIndex && indexHtmlPath !== null;
|
||||
try {
|
||||
const bundle = await rollup({
|
||||
onwarn: onRollupWarning(spinner, config.optimizeDeps),
|
||||
...inputOptions,
|
||||
plugins: [
|
||||
...(inputOptions.plugins || []).filter(
|
||||
// remove vite:emit in case this build copied another build's plugins
|
||||
(plugin) => plugin.name !== 'vite:emit'),
|
||||
// vite:emit
|
||||
createEmitPlugin(emitAssets, async (assets) => {
|
||||
indexHtml = emitIndex ? await renderIndex(assets) : '';
|
||||
result = { build, assets, html: indexHtml };
|
||||
if (onResult) {
|
||||
await onResult(result);
|
||||
}
|
||||
// run post-build hooks sequentially
|
||||
await postBuildHooks.reduce((queue, hook) => queue.then(() => hook(result)), Promise.resolve());
|
||||
if (write) {
|
||||
if (i === 0) {
|
||||
await fs_extra_1.default.emptyDir(outDir);
|
||||
}
|
||||
if (emitIndex) {
|
||||
indexHtmlPath = path_1.default.join(outDir, indexHtmlPath);
|
||||
await fs_extra_1.default.writeFile(indexHtmlPath, indexHtml);
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
await bundle[write ? 'write' : 'generate']({
|
||||
dir: resolvedAssetsPath,
|
||||
format: 'es',
|
||||
sourcemap,
|
||||
entryFileNames: `[name].[hash].js`,
|
||||
chunkFileNames: `[name].[hash].js`,
|
||||
assetFileNames: `[name].[hash].[ext]`,
|
||||
...outputOptions
|
||||
});
|
||||
}
|
||||
finally {
|
||||
spinner && spinner.stop();
|
||||
}
|
||||
if (write && !silent) {
|
||||
if (emitIndex) {
|
||||
printFileInfo(indexHtmlPath, indexHtml, 3 /* HTML */);
|
||||
}
|
||||
for (const chunk of result.assets) {
|
||||
if (chunk.type === 'chunk') {
|
||||
const filePath = path_1.default.join(resolvedAssetsPath, chunk.fileName);
|
||||
printFileInfo(filePath, chunk.code, 0 /* JS */);
|
||||
if (chunk.map) {
|
||||
printFileInfo(filePath + '.map', chunk.map.toString(), 4 /* SOURCE_MAP */);
|
||||
}
|
||||
}
|
||||
else if (emitAssets && chunk.source)
|
||||
printFileInfo(path_1.default.join(resolvedAssetsPath, chunk.fileName), chunk.source, chunk.fileName.endsWith('.css') ? 1 /* CSS */ : 2 /* ASSET */);
|
||||
}
|
||||
}
|
||||
spinner && spinner.start();
|
||||
return result;
|
||||
});
|
||||
// copy over /public if it exists
|
||||
if (write && emitAssets && fs_extra_1.default.existsSync(publicDir)) {
|
||||
for (const file of await fs_extra_1.default.readdir(publicDir)) {
|
||||
await fs_extra_1.default.copy(path_1.default.join(publicDir, file), path_1.default.resolve(outDir, file));
|
||||
}
|
||||
}
|
||||
spinner && spinner.stop();
|
||||
if (!silent) {
|
||||
console.log(`Build completed in ${((Date.now() - start) / 1000).toFixed(2)}s.\n`);
|
||||
}
|
||||
// stop the esbuild service after each build
|
||||
await esbuildService_1.stopService();
|
||||
return results;
|
||||
}
|
||||
exports.build = build;
|
||||
/**
|
||||
* Bundles the app in SSR mode.
|
||||
* - All Vue dependencies are automatically externalized
|
||||
* - Imports to dependencies are compiled into require() calls
|
||||
* - Templates are compiled with SSR specific optimizations.
|
||||
*/
|
||||
async function ssrBuild(options) {
|
||||
const { rollupInputOptions, rollupOutputOptions, rollupPluginVueOptions } = options;
|
||||
return build({
|
||||
outDir: 'dist-ssr',
|
||||
...options,
|
||||
rollupPluginVueOptions: {
|
||||
...rollupPluginVueOptions,
|
||||
target: 'node'
|
||||
},
|
||||
rollupInputOptions: {
|
||||
...rollupInputOptions,
|
||||
external: resolveExternal(rollupInputOptions && rollupInputOptions.external)
|
||||
},
|
||||
rollupOutputOptions: {
|
||||
...rollupOutputOptions,
|
||||
format: 'cjs',
|
||||
exports: 'named',
|
||||
entryFileNames: '[name].js',
|
||||
// 764 add `Symbol.toStringTag` when build es module into cjs chunk
|
||||
namespaceToStringTag: true
|
||||
},
|
||||
emitIndex: false,
|
||||
emitAssets: false,
|
||||
cssCodeSplit: false,
|
||||
minify: false
|
||||
});
|
||||
}
|
||||
exports.ssrBuild = ssrBuild;
|
||||
function createEmitPlugin(emitAssets, emit) {
|
||||
return {
|
||||
name: 'vite:emit',
|
||||
async generateBundle(_, output) {
|
||||
// assume the first asset in `output` is an entry chunk
|
||||
const assets = Object.values(output);
|
||||
// process the output before writing
|
||||
await emit(assets);
|
||||
// write any assets injected by post-build hooks
|
||||
for (const asset of assets) {
|
||||
output[asset.fileName] = asset;
|
||||
}
|
||||
// remove assets from bundle if emitAssets is false
|
||||
if (!emitAssets) {
|
||||
for (const name in output) {
|
||||
if (output[name].type === 'asset') {
|
||||
delete output[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resolve the output path of `index.html` for the given build (relative to
|
||||
* `outDir` in Vite config).
|
||||
*/
|
||||
function getIndexHtmlOutputPath(build) {
|
||||
const { input, output } = build;
|
||||
return input === 'index.html' ? output.file || input : null;
|
||||
}
|
||||
function resolveExternal(userExternal) {
|
||||
const required = ['vue', /^@vue\//];
|
||||
if (!userExternal) {
|
||||
return required;
|
||||
}
|
||||
if (Array.isArray(userExternal)) {
|
||||
return [...required, ...userExternal];
|
||||
}
|
||||
else if (typeof userExternal === 'function') {
|
||||
return (src, importer, isResolved) => {
|
||||
if (src === 'vue' || /^@vue\//.test(src)) {
|
||||
return true;
|
||||
}
|
||||
return userExternal(src, importer, isResolved);
|
||||
};
|
||||
}
|
||||
else {
|
||||
return [...required, userExternal];
|
||||
}
|
||||
}
|
||||
function printFileInfo(filePath, content, type) {
|
||||
const needCompression = type === 0 /* JS */ || type === 1 /* CSS */ || type === 3 /* HTML */;
|
||||
const compressed = needCompression
|
||||
? `, brotli: ${(require('brotli-size').sync(content) / 1024).toFixed(2)}kb`
|
||||
: ``;
|
||||
console.log(`${chalk_1.default.gray(`[write]`)} ${writeColors[type](path_1.default.relative(process.cwd(), filePath))} ${(content.length / 1024).toFixed(2)}kb${compressed}`);
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/vite/dist/node/build/index.js.map
generated
vendored
Normal file
1
node_modules/vite/dist/node/build/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user