简体   繁体   English

从Java服务器使用Webpack构建React视图

[英]Building React views with Webpack from a Java server

I'm currently developing a front end app with React.js, using Webpack for the build. 我目前正在使用Webpack开发带有React.js的前端应用程序。 For the development process, I'm using Webpack Dev Server, which is fine for my own purposes. 在开发过程中,我使用的是Webpack Dev Server,这对于我自己的目的是很好的。 I have configured production Webpack builds from Node.js servers and am comfortable with how that works. 我已经从Node.js服务器配置了生产Webpack构建,并对它的工作方式很满意。

For this project, however, the server is being written in Java. 但是,对于该项目,服务器是用Java编写的。 How would one go about performing the Webpack build process in this environment? 在这种环境下如何执行Webpack构建过程?

Having forgotten about this question for some time, I just looked at my profile and realized that I do know the answer. 忘记这个问题已有一段时间了,我只是看了一下个人资料,便意识到我确实知道答案。 And the answer is: 答案是:

You Can't 你不能

Webpack is a Node.js process, and would need to be run on a Node.js server. Webpack是一个Node.js进程,需要在Node.js服务器上运行。 Now, you'd actually probably be able to run a concurrent Node process just to build the front-end stuff with Webpack. 现在,您实际上可能能够运行一个并发的Node进程,而只是使用Webpack构建前端的东西。 The other option would be to throw React and your dependencies into whichever directory you're serving your JS scripts from. 另一个选择是将React和您的依赖项放到您要为其提供JS脚本的目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使 webpack typescript 响应 webpack-dev-server 配置以自动构建和重新加载页面 - how to make webpack typescript react webpack-dev-server configuration for auto building and reloading page 从 webpack 包中排除 react、react-dom 以构建反应库 - Exclude react, react-dom from webpack bundle for building react library React Webpack和服务器 - React Webpack and a server 无需构建步骤即可启动 webpack 开发服务器 - Start webpack dev server without the building step webpack和lite-server进行反应 - webpack and lite-server for react 使用 webpack 服务器部署 React 应用程序 - Deploying react app with webpack server 我在服务器控制台中构建反应应用程序时出现此错误“未捕获的 ReferenceError:在初始化之前无法访问'__WEBPACK_DEFAULT_EXPORT__'” - I have this error in building react app in server console "Uncaught ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization" 使用 create-react-app 和 webpack dev server 将来自客户端反应应用程序的请求代理到服务器 - Proxying requests from client react app to server with create-react-app and webpack dev server 使用webpack 3进行react-loadable和服务器端渲染 - react-loadable and server side rendering with webpack 3 反应服务器端渲染与webpack - React server-side rendering vs webpack
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM