问题描述
我在 dist 文件夹中有:index.PHP 而不是 index.html 并且想用 webpack-dev-server 打开。在当前设置下,当 dev-server 启动时,它只下载 index.PHP 文件。
如何设置 webpack-dev-server - 正常打开:index.PHP? 我尝试了几件事,但没有任何效果。 我使用 WAMP,项目根文件夹位于 www 文件夹内。
devServer: {
port: 3000,open: "Chrome",stats: "minimal",historyApiFallback: {
index: '/index.PHP',},//index: "index.PHP",//contentBase: "./dist",//historyApiFallback: true
}
webpack.dev.js:
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const copyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const WebpackBar = require("webpackbar");
module.exports = {
mode: "development",entry: path.resolve(__dirname,"./src/index.js"),output: {
path: path.resolve(__dirname,"dist"),filename: "js/[name].js",stats: {
modules: false,entrypoints: false,devtool: "eval-source-map",plugins: [
new WebpackBar({}),new CleanWebpackPlugin({}),new copyPlugin({
patterns: [
{ from: "src/img",to: "img" },],}),new MiniCssExtractPlugin({
filename: "css/main.css"
}),new HtmlWebpackPlugin({
template: "./src/index.PHP",filename: 'index.PHP',inject: "body"
})
],module: {
rules: [
{
test: /\.css$/,use: [
MiniCssExtractPlugin.loader,{ loader: "css-loader",options: { url: false } },{ loader: "postcss-loader",options: {} },}
]
},devServer: {
compress: true,port: 3000,historyApiFallback: {
index: '/index.PHP',//hot: true,}
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)