Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在apache服务器上部署没有index.html的react应用程序进行生产_Javascript_Reactjs_Webpack - Fatal编程技术网

Javascript 如何在apache服务器上部署没有index.html的react应用程序进行生产

Javascript 如何在apache服务器上部署没有index.html的react应用程序进行生产,javascript,reactjs,webpack,Javascript,Reactjs,Webpack,我有一个React应用程序没有index.html页面。我的第一个反应应用程序,所以请考虑我的专业水平。 这里有很多答案,但当没有索引html入口点时就没有了 我已经在apache的XAMPP上成功运行了这个应用程序,以便在localhost:7000(no index.html)上开发。这很好,因为我的网页包在内存中加载了一个捆绑js。我使用命令“server”:“node app.js”,运行热加载本地服务器 这是我的网页配置的一部分 module.exports = { entry

我有一个React应用程序没有index.html页面。我的第一个反应应用程序,所以请考虑我的专业水平。 这里有很多答案,但当没有索引html入口点时就没有了

我已经在apache的XAMPP上成功运行了这个应用程序,以便在localhost:7000(no index.html)上开发。这很好,因为我的网页包在内存中加载了一个捆绑js。我使用命令
“server”:“node app.js”,
运行热加载本地服务器

这是我的网页配置的一部分

  module.exports = {
  entry: './src/main.js',
  output: {
    path: join(__dirname, '/dist/js/'),
    filename: 'bundle.js',
    publicPath: '/',
  },
到目前为止,我所拥有的:

  • 我已将webpack配置为将单个捆绑js文件写入我的dist/js文件夹
  • 我将所有图像存储在dist/images文件夹中
  • 我添加了上述所有文件夹,并将js捆绑到XAMPP(htdocs)文件夹的根目录中
以下是我为Dev工作的目录结构:

config
dist
node_modules
routes (contains all routes for the App)
src (Has all components and entry is main.js)
styles (Has scss but it gets compiled into a single dist/styles/style.css)
views (Has all handle bar files for views)
-app.js (Main entry with express and webpack config references)
-app-routes (routes for the app)
-env,js(Has environment variables such as database connection details, port)
-webpack.config.js
-nodemon.json
-package.json
纱线运行prod
之后,我得到一个dist文件夹,如下所示

images (all images for app)
js (contains bundle.js file)
styles (contains compiled style.css)

我应该向htdocs根文件夹添加哪些文件

在你的
webpack.config.js
插件中添加

plugins: [
  new HtmlWebpackPlugin({
    template: './src/index.html',
    filename: './index.html'
  }),
],
在顶端的某个地方做这个

var HtmlWebpackPlugin = require('html-webpack-plugin');
在你的插件中添加这个

plugins: [
  new HtmlWebpackPlugin({
    template: './src/index.html',
    filename: './index.html'
  }),
],
这将创建一个index.html文件,并将
.js
.css
文件(如果有的话)插入到html文件中


您可以阅读此网页插件的更多信息,以生成动态index.html文件

谢谢-我没有任何html文件。
模板:'./src/index.html',
。。我正在使用Handlebar,页面标题等都是使用Handlebar构建的。我需要查看您的代码配置,但如果它只是一个apache服务器。只需生成动态
index.html
文件并让它完成工作。手柄可能会使代码过于复杂。