将项目设置成ip访问

版权声明:转载请注明来源 https://blog.csdn.net/weixin_41829196/article/details/88743299

1.dev-server :

devServer: {
		// 指定启动服务的更目录
		host: '0.0.0.0',
		contentBase: __dirname + '/src',
		port: 4000,
		hot: true,// 是否启用热更新
		inline: true, // 默认是true
		historyApiFallback: true,
		noInfo: false,
		disableHostCheck: true,
		open: true
		// stats: 'minimal',
		// publicPath: publicPath
	},

2.publicPath:

output: {
		path: path.resolve(__dirname, 'src/js'),
		publicPath: "http://192.168.1.86:4000/js/",
		// 主要是这个
		chunkFilename: "[id].build.js?[chunkhash]",
		filename: '[name].js',
	},

3.index.html

<!DOCTYPE html>
<html lang="en">
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta charset="UTF-8">
	<title>Title</title>
	<link rel="stylesheet" href="//res.wx.qq.com/open/libs/weui/1.1.3/weui.min.css">
</head>
<body>
<div id="agent"></div>
<script src="http://192.168.1.86:4000/js/agent.js"></script>
<script src="//res.wx.qq.com/open/libs/weuijs/1.1.4/weui.min.js"></script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_41829196/article/details/88743299