2023年7月7日发(作者:)
在⽣产中部署应⽤Deploying an app made using in production is easy. Add those 3 lines to the script section:在⽣产环境中部署使⽤创建的应⽤程序很容易。 将这三⾏添加到 script部分:"scripts": { "dev": "next", "build": "next build", "start": "next start"}We used npm run dev up to now, to call the next command installed locally in node_modules/next/dist/bin/next. This started thedevelopment server, which provided us source maps and hot code reloading, two very useful features while debugging.到⽬前为⽌,我们使⽤npm run dev来调⽤本地安装在node_modules/next/dist/bin/next的next命令。 这启动了开发服务器,该服务器向我们提供了源映射和热代码重载 ,这是调试时的两个⾮常有⽤的功能。The same command can be invoked to build the website passing the build flag, by running npm run build. Then, the samecommand can be used to start the production app passing the start flag, by running npm run start.通过运⾏npm run build ,可以调⽤相同的命令来构建通过build标记的⽹站。 然后,通过运⾏npm run start ,可以使⽤同⼀命令通过start标志来启动⽣产应⽤程序。Those 2 commands are the ones we must invoke to successfully deploy the production version of our site locally. Theproduction version is highly optimized and does not come with source maps and other things like hot code reloading thatwould not be beneficial to our end users.这两个命令是我们必须调⽤以成功在本地部署站点的⽣产版本的命令。 ⽣产版本经过⾼度优化,并且不附带源地图和诸如热代码重新加载之类的对我们最终⽤户⽆益的东西。So, let’s create a production deploy of our app. Build it using:因此,让我们创建应⽤程序的⽣产部署。 使⽤以下命令进⾏构建:npm run buildThe output of the command tells us that some routes (/ and /blog are now prerendered as static HTML, while /blog/[id] will beserved by the backend.该命令的输出告诉我们,某些路由( /和/blog现在已预先呈现为静态HTML,⽽/blog/[id]将由后端提供服务。Then you can run npm run start to start the production server locally:然后,您可以运⾏npm run start在本地启动⽣产服务器:npm run startVisiting will show us the production version of the app, locally.访问将向我们展⽰该应⽤的⽣产版本。翻译⾃:
发布者:admin,转转请注明出处:http://www.yc00.com/web/1688683228a162181.html
评论列表(0条)