Javascript 网页包忽略端口设置
我试图通过WebPack运行我的React应用程序,但该工具似乎忽略了我的端口设置。相反,它使用默认的Javascript 网页包忽略端口设置,javascript,webpack,Javascript,Webpack,我试图通过WebPack运行我的React应用程序,但该工具似乎忽略了我的端口设置。相反,它使用默认的8080端口或随机端口(每次运行项目时都会有所不同)。以下是我的webpack.development.config.js文件的摘录: const path = require('path') const appJsPath = path.join(__dirname, './src') const bundelJsPath = path.join(__dirname, './build')
8080
端口或随机端口(每次运行项目时都会有所不同)。以下是我的webpack.development.config.js
文件的摘录:
const path = require('path')
const appJsPath = path.join(__dirname, './src')
const bundelJsPath = path.join(__dirname, './build')
module.exports = {
devtool: 'inline-cheap-module-source-map',
context: appJsPath,
mode: 'development',
entry: {
myApp: [
'babel-polyfill',
'./main.js'
]
},
devServer: {
contentBase: path.join(bundelJsPath, '[name].bundle.js'),
port: 4040
},
// output: {
// path: bundelJsPath,
// filename: '[name].bundle.js',
// publicPath: 'http://localhost:4000/'
// },
我已经检查了端口4000
和4040
,它们没有被任何进程使用(我在Windows 10系统上)。我尝试了两种设置,devServer
和output
,但它们都不起作用。重新启动系统也无济于事。我做错了什么
我正在通过运行warn dev
启动应用程序:
"scripts": {
"dev": "yarn run clean && webpack-serve --config ./webpack.development.config.js && yarn run css",
"clean": "rimraf ./build",
"css": "uglifycss ./css/style.css > ./css/style.min.css"
}
如何启动dev服务器?我们可以看到npm脚本吗?我已经添加了相关的脚本。为什么不使用webpack dev server?我不知道,这是一个我正在尝试更新的遗留应用程序。