- 在laya项目目录下新建
package.json
点击查看代码
| { |
| "scripts": { |
| "bundle:dev": "webpack --config webpack.config.debug.js --watch", |
| "serve": "webpack serve --config webpack.config.debug.js" |
| }, |
| "jest": { |
| "testEnvironment": "node" |
| }, |
| "devDependencies": { |
| "@types/jest": "^26.0.20", |
| "flatbuffers": "^1.12.0", |
| "jest": "^26.6.3", |
| "protobufjs": "^6.10.1", |
| "raw-loader": "^4.0.1", |
| "source-map-support": "^0.5.20", |
| "ts-jest": "^26.5.3", |
| "ts-loader": "^8.0.3", |
| "tsconfig-paths-webpack-plugin": "^3.3.0", |
| "tslint": "^6.1.3", |
| "typescript": "^4.0.2", |
| "webpack": "^4.44.1", |
| "webpack-bundle-analyzer": "^3.8.0", |
| "webpack-cli": "^4.10.0", |
| "webpack-dev-server": "^4.11.1", |
| "yaml-loader": "^0.6.0" |
| }, |
| "dependencies": { |
| "@types/flatbuffers": "^1.10.0", |
| "inkjs": "^1.11.0" |
| }, |
| "name": "diudiu", |
| "version": "1.0.0", |
| "main": "webpack.config.debug.js", |
| "author": "", |
| "license": "ISC", |
| "description": "" |
| } |
| |
- 在
tsconfig.json
设置
点击查看代码
| { |
| "compilerOptions": { |
| "module": "es6", |
| "target": "es6", |
| "noEmitHelpers": true, |
| "sourceMap": true, |
| "inlineSources": true |
| }, |
| "exclude": [ |
| "node_modules" |
| ] |
| } |
- 在项目根目录新建
webpack.config.debug.js
配置设置文件
点击查看代码
| const path = require('path'); |
| |
| |
| const externals = { |
| }; |
| |
| module.exports = { |
| entry: path.join(__dirname, 'src/Main.ts'), |
| devtool: 'inline-source-map', |
| mode: 'development', |
| module: { |
| rules: [ |
| { |
| test: /\.tsx?$/, |
| use: 'ts-loader', |
| exclude: /node_modules/ |
| }, |
| { test: /\.fs$/, use: 'raw-loader' }, |
| { test: /\.vs$/, use: 'raw-loader' } |
| ] |
| }, |
| resolve: { |
| extensions: ['.tsx', '.ts', '.js'], |
| |
| }, |
| output: { |
| filename: 'bundle.js', |
| path: path.resolve(__dirname, 'bin/js') |
| }, |
| devServer: { |
| static: { |
| directory: path.join(__dirname, 'bin') |
| }, |
| historyApiFallback: true, |
| compress: true, |
| hot:true, |
| port: '5000', |
| open: true |
| }, |
| externals |
| }; |
- 在项目根目录执行命令
npm install
安装所有库
- 执行命令
npm run bundle:dev
编译项目,尝试一下修改项目代码然后按保存,看看是否会编译项目,会自动编译就对了。
- 再执行
npm run serve
运行本地HTTP
服务器。
- 看到运行效果了,完美执行。如果需要按
F5
就运行这个项目就再VS Code
里面设置一下编译再运行就好了。

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧