feat:wait-on使用ip,使用localhost无法启动

This commit is contained in:
1708-huayu 2024-09-25 13:27:25 +08:00
parent 3b7d8f14c3
commit b6b1847b92
3 changed files with 27 additions and 11 deletions

View File

@ -14,25 +14,41 @@ module.exports = {
}, },
}, },
], ],
alias: {
// 将@/*映射为src目录
'@': path.resolve(__dirname, 'src/'),
},
webpack: { webpack: {
alias:{ entry: {
'@': path.resolve(__dirname, 'src/') main: ['whatwg-fetch', './src/index.js'],
}, },
configure: (webpackConfig, { env, paths }) => { configure: (webpackConfig, { env, paths }) => {
// 修改output.publicPath为'./' // 修改output.publicPath为'./'
// webpackConfig.output.publicPath = './'; // webpackConfig.output.publicPath = './';
// webpackConfig.output.path = path.join(__dirname,"/build");
// webpackConfig.output.publicPath = "./";
webpackConfig.output.path = path.join(__dirname,); webpackConfig.output.path = path.join(__dirname,);
webpackConfig.output.publicPath = ""; webpackConfig.output.publicPath = "";
// webpackConfig.output.module
// .rule("icons")
// .test(/\.svg$/)
// .include.add(resolve("src/icons"))
// .end()
// .use("svg-sprite-loader")
// .loader("svg-sprite-loader")
// .options({
// symbolId: "icon-[name]",
// })
// .end()
return webpackConfig; return webpackConfig;
}, },
alias: {
// 将@/*映射为src目录
'@': path.resolve(__dirname, 'src/'),
},
// 确保入口文件正确
// entry: {
// main: ['whatwg-fetch', './src/index.js'],
// },
}, },
devServer: { devServer: {
port: 3005, // 设置端口 port: 3008, // 设置端口
}, },
}; };

View File

@ -21,7 +21,7 @@ const createWindow = () => {
console.log("isDev", isDev) console.log("isDev", isDev)
if (isDev){ if (isDev){
// 加载 index.html // 加载 index.html
win.loadURL('http://localhost:3005') win.loadURL('http://localhost:3008')
// 打开开发工具 // 打开开发工具
win.webContents.openDevTools() win.webContents.openDevTools()
}else { }else {

View File

@ -54,7 +54,7 @@
"yjs": ">=13.5.42" "yjs": ">=13.5.42"
}, },
"scripts": { "scripts": {
"dev": "concurrently \"wait-on http://localhost:3005 && electron .\" \"cross-env BROWSER=none npm start\"", "dev": "concurrently \"wait-on --log http://127.0.0.1:3008 && electron .\" \"cross-env BROWSER=none npm start\"",
"start": "craco start --verbose", "start": "craco start --verbose",
"build": "craco build", "build": "craco build",
"startel": "set NODE_ENV=development&&electron .", "startel": "set NODE_ENV=development&&electron .",