UNPKG

@build-script/heft-esbuild-plugin

Version:

lowlevel esbuild plugin for [heft]

79 lines (78 loc) 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.filterOptions = filterOptions; const node_path_1 = require("node:path"); const common_1 = require("@idlebox/common"); function required(options, key) { if (typeof options[key] === 'undefined') throw new Error(`${key} is required`); } function denied(options, key) { if (typeof options[key] !== 'undefined') throw new Error(`${key} is denied`); } function filterOptions(rootDir, options) { required(options, 'outdir'); required(options, 'entryPoints'); denied(options, 'outfile'); denied(options, 'absWorkingDir'); options = Object.assign({}, defaultOptions, options); options.loader = Object.assign({}, defaultOptions.loader, options.loader); if (options.platform === 'browser') { options.mainFields = ['browser', 'module', 'main']; options.conditions = ['browser', 'import', 'default']; } else if (options.platform === 'node') { } const outputDir = (0, common_1.normalizePath)((0, node_path_1.resolve)(rootDir, `./${options.outdir}`)); if (!outputDir.startsWith(rootDir)) { throw new Error(`output dirctory is out of root: ${outputDir}`); } if (outputDir === rootDir) { throw new Error(`output dirctory is root: ${options.outdir}`); } options.outdir = outputDir; options.absWorkingDir = rootDir; options.write = false; options.metafile = true; return options; } const defaultOptions = { bundle: true, splitting: false, platform: 'browser', assetNames: 'assets/[name][ext]', resolveExtensions: ['.ts', '.tsx', '.js'], external: ['electron'], loader: { '.xml': 'text', '.txt': 'text', '.md': 'text', '.png': 'dataurl', '.ico': 'dataurl', '.gif': 'file', '.jpg': 'file', '.jpeg': 'file', '.webp': 'file', '.svg': 'text', '.woff2': 'file', '.woff': 'file', '.ttf': 'file', '.eot': 'file', '.otf': 'file', '.sfnt': 'file', }, sourcemap: 'linked', sourcesContent: false, keepNames: true, charset: 'utf8', target: 'esnext', // plugins: [ // // SkipElectronPlugin(), // ScssCombinePlugin(session, { // // TODO // sourceRoot: './src', // }), // ], }; //# sourceMappingURL=config.js.map