@alauda/custom-webpack
v5.2.10
Published
Custom webpack configuration with alauda dev server and other great features
Maintainers
Keywords
Readme
@alauda/custom-webpack
Custom webpack configuration with alauda dev server and other great features
发版操作指引
如果你要通过 PAC 发布 @alauda/custom-webpack,按下面的最短路径走:
从
master拉最新代码并创建功能分支。完成改动后执行
yarn changeset补一条 changeset。本地执行:
yarn lint yarn build npm pack --dry-run推送分支,并创建一个目标分支为
master的 merge request。在 merge request 里评论
/publish-preview。等待 preview 成功回帖,并拿到
preview-mr-<iid>的安装命令。合并功能 merge request 到
master。等待 PAC 自动创建
changeset-release/master这条 release merge request。合并这条 release merge request 到
master。等待最后一条 PAC 流水线发布稳定版本。
快速入口:
What features are included?
- Seamlessly open browser on development, it will try its best to reuse opened browser tab, so that no more redundant browser tabs will be opened like
webpack-dev-server --open - If you've installed global console-cli, it will start the console backend server on development or
serveon production mode. What means there will be no need to clone alauda-console and runmake devby yourself. Of course, you'll need to provide a console config file at~/.consolerc.yml(or any other valid configuration supported by cosmiconfig) withauthentication.oidc_client_secret,authentication.oidc_issuer_urlandconsole.api_address. - Restart console service automatically on configuration changes.
- Bundle with and inject service worker on production automatically.
- Proxy to alauda console automatically on development and
serveon production mode. - Provide
html-minifierwrapperhmto minifyindex.htmlwith common default options. dev-consoleserver for development which enables auto-login and no cross-origin (a console config like~/.consolerc.ymlis required)- Disable proxy api gateway for
dev-consoleso that HTTP2 connection could be enabled for api gateway - Change alauda console environment quickly with
ccecommand fordev-consoleorconsole-cli - Proxy with HTTPS support when running with
ng serve --ssl
Upcoming Features
- HTTP2 support
Other incredible features from you.
Usage
Simplest
Install Dependencies:
yarn add -D @alauda/custom-webpack @angular-builders/custom-webpackConfig
angular.json:// production { "builder": "@angular-builders/custom-webpack:browser", "options": { "customWebpackConfig": { "path": "node_modules/@alauda/custom-webpack" } } }// development { "builder": "@angular-builders/custom-webpack:dev-server" }Config
~/.consolerc.yml(required forconsole-cliordev-console)authentication: http_proxy: proxy_url https_proxy: proxy_url no_proxy: localhost,127.0.0.1,0.0.0.0 login: login password: password console: api_address: api_address use_platform_api: false # optional, turn true to use /console-platform/api defaultUser: # optional login: login password: password envs: - name: env_name # optional api_address: api_address # required login: login # optional, will fallback to #defaultUser.login password: password # optional, will fallback to #defaultUser.password use_platform_api: false # optionalrun
ng serve, that's all, hope you like the development workflow.
Commands
Serve on production mode
yarn sMinify index.html on building
// package.json
{
"scripts": {
"postbuild": "hm"
}
}Change console env
cce # you can choose to install `@alauda/custom-webpack` globally
? Which alauda console env do you want to use? …
a https://a.example.com (adminA)
b https://b.example.com (adminB)
cce - a # quickly change to specify envList envs
cce list
activeEnv: a
┌─────────┬──────────┬─────────────────────────┬─────────────────┬───────────────────┬──────────────────┐
│ (index) │ name │ api_address │ login │ password │ use_platform_api │
├─────────┼──────────┼─────────────────────────┼─────────────────┼───────────────────┼──────────────────┤
│ 0 │ 'a' │ 'https://a.example.com' │ 'adminA' │ 'passwordA' │ │
│ 1 │ 'b' │ 'https://b.example.com' │ 'adminB' │ 'passwordB' │ true │
└─────────┴──────────┴─────────────────────────┴─────────────────┴───────────────────┴──────────────────┘Advanced
If your need to custom the configuration again on top of @alauda/custom-webpack, you can simply provide a file named webpack.config.js, and config angular.json:
// production
{
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "webpack.config.js"
}
}
}// webpack.config.js
import { createRequire } from 'node:module'
import customWebpack from '@alauda/custom-webpack'
const require = createRequire(import.meta.url)
export default config => {
Object.assign(customWebpack(config).resolve.alias, {
moment$: 'dayjs/esm',
'moment-timezone$': require.resolve('./src/app/timezone'),
})
// mutate anything you want after calling `customWebpack(config)`
return config
}Environments
ALAUDA_DISABLE_LAZY_COMPILE: Whether to disable lazy compile on development.ALAUDA_DISABLE_START_CONSOLE: Whether to disable starting console server automatically, not required ifALAUDA_ENABLE_DEV_CONSOLEis trueALAUDA_ENABLE_DEV_CONSOLE: Whether to enable dev console server automatically (highly unrecommended).ALAUDA_DISABLE_PROXY_API_GATEWAY: Whether to disable proxy api gateway, if true then the true api address will be used instead,ALAUDA_ENABLE_DEV_CONSOLEis required to take effect
Useful Internal API
startConsole:Control when or whether to start the (dev) console server in background on
spawnmode.import { startConsole } from '@alauda/custom-webpack/start-console'Anything you want us to expose?
PAC 流水线
如果你只想知道怎么发版,先看:
如果你想了解为什么流水线这样设计,再看:
v4 流水线基于原生 Tekton 和 Tekton Pipelines as Code 定义:
- PipelineRun:
.tekton/pipeline-runs/custom-webpack.yaml - Pipeline:
.tekton/pipelines/custom-webpack-release.yaml
PipelineRun 名称是 custom-webpack,因此通用的 PAC 测试命令仍然可用:
/test custom-webpack
/test custom-webpack branch:master发版相关的手工命令为:
/publish-preview如果需要在 edge 环境继续排查 PAC 失败,直接看这份仓库内速查手册:
完整操作手册和设计说明已经拆到独立文档:
