lwc是一个web components开发工具。
pnpm create lwr
选择SPA。项目生成后,一些运行时包并不在package.json
中,需手动安装。
package.json
:
{
"name": "lwrdemo",
"version": "0.0.1",
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"clean": "rimraf node_modules __lwr_cache__ site",
"dev": "lwr dev",
"dev:compat": "lwr dev --mode compat",
"build": "lwr build --clean",
"build:prod-compat": "lwr build --clean --mode prod-compat",
"start": "lwr start",
"stage": "yarn build && yarn start",
"stage:prod-compat": "yarn build:prod-compat && yarn start"
},
"dependencies": {
"@lwc/engine-dom": "^7.1.3",
"@lwc/synthetic-shadow": "^7.1.3",
"@lwrjs/client-modules": "^0.13.7",
"@lwrjs/loader": "^0.13.7",
"@lwrjs/o11y": "^0.13.7",
"@lwrjs/router": "^0.13.7",
"lwc": "latest",
"lwr": "0.13.7"
},
"engines": {
"node": ">=18.0.0"
},
"volta": {
"node": "20.15.1"
}
}
然后执行pnpm dev
就可以开发了,pnpm build
生成正式包。