@infrastructure.dev/builder
v0.0.1
Published
common bundler and dev server
Downloads
4
Readme
Dev builder
// sample ./dev-builder.config.js
const sourcePath = __dirname;
module.exports = (type, env) => {
const environmentKey = env.environment || "dev";
return {
sourcePath: sourcePath,
indexFile: "./src/index.ts",
outputDir: "./dist",
outputLibraryFileName: "index",
tsConfigFile: "./tsconfig.json",
externals: [],
environment: {
ENV_KEY: environmentKey,
NODE_ENV: environmentKey !== "dev" ? "production" : "development",
},
html: type!=='build',
plugin: false,
library: type==='build',
optimize: environmentKey !== "dev",
sourceMap: true,
htmlTemplate: "./src/index.html",
devServer: {
host: "127.0.0.1",
port: 4200,
},
};
};
// sample ./package.json
{
"scripts": {
// defaults:
// --config (alias: -c) ./dev-builder.config.js
// --env.environment=dev"
// --debug (alias: -d) false
// --quiet (alias: -q) false
// --verbose (alias: -v) false
"serve": "dev-builder run server",
"build": "dev-builder run build --env.environment=prod",
"build-esm": "dev-builder run build-esm --env.environment=prod",
"serve-explicitly": "dev-builder run server -dv --config ./dev-builder.config.js --env.environment=dev",
"build-explicitly": "dev-builder run build -dv --config ./dev-builder.config.js --env.environment=prod"
}
}