1. package.json
添加
{
"scripts": {
"build": "node --preserve-symlinks node_modules/webpack/bin/webpack.js --config content/panorama/xxx/xxx/webpack.config.js",
"dev": "node --preserve-symlinks node_modules/webpack/bin/webpack.js --config content/panorama/xxx/xxx/webpack.config.js --watch"
}
}
2. 使用命令 node --preserve-symlinks node_modules/webpack/bin/webpack.js
3. 使用命令 npm install -D webpack@next webpack-cli webpack-panorama
4. 创建文件 webpack.config.js
,路径在第一步第二个参数,并复制下面内容保存,注意需要修改被我添加了xxx
的路径为具体需要处理合并的目标,路径都是相对于webpack.config.js
const path = require('path');
const { PanoramaTargetPlugin } = require('webpack-panorama');
/** @type {import('webpack').Configuration} */
module.exports = {
entry: {
hud: './hud/xxx/script.js',
},
mode: 'development',
context: path.resolve(__dirname, 'src/xxx/'),
output: {
path: path.resolve(__dirname, 'scripts/xxx/custom_game'),
},
resolve: {
// Required because of reverse symlinking
symlinks: false,
},
plugins: [new PanoramaTargetPlugin()],
};
5. 执行命令 npm run build
看是否有错,没错就开启Watch(npm run dev
)
- 安装好以后编辑
webpack.config.js
的module
块
- ts注意最后编辑的
tsconfig.json
文件的include
值为具体的目录名