参考 https://nuxtjs.org/guide/commands/#single-page-application-deployment-spa-
SSR模式虽然有很好的SEO支持【服务端预渲染】,但是由于我们网站的内容是基于实时API,部分也基于user authentication的,所以采用SPA方式发布。 大部分内容都是固定的,只是数据来源是API获取。采用SSR模式,并且开始https支持。
参考 https://nuxtjs.org/guide/commands#server-side-rendered-deployment-universal-ssr-
To deploy, instead of running nuxt, you probably want to build ahead of time. Therefore, building and starting are separate commands:
nuxt build nuxt start
You can also set server.https in your nuxt.config.js with the same set of options passed to https.createServer, should you choose to serve Nuxt.js in HTTPS mode. Unix sockets are also available if you set the server.socket option in nuxt.config.js (or -n in the CLI). When using Unix sockets, make sure not to set the host and port parameters otherwise the socket parameter is ignored.The package.json like follows is recommended:
{ "name": "my-app", "dependencies": { "nuxt": "latest" }, "scripts": { "dev": "nuxt", "build": "nuxt build", "start": "nuxt start" } }开发的时候其实就已经会有上面的配置了:
Note: we recommend putting .nuxt in .npmignore or .gitignore.默认 .nuxt文件夹就存在,.gitignore在git 使用之后也是存在的,.npmignore参考官方声明,如果有.gitignore了可以直接在其中添加 ,具体参考 https://docs.npmjs.com/using-npm/developers.html#keeping-files-out-of-your-package
摘抄如下:
Use a .npmignore file to keep stuff out of your package. If there’s no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file. If you want to include something that is excluded by your .gitignore file, you can create an empty .npmignore file to override it. Like git, npm looks for .npmignore and .gitignore files in all subdirectories of your package, not only the root directory.
.npmignore files follow the same pattern rules as .gitignore files:
Blank lines or lines starting with # are ignored.
Standard glob patterns work.
You can end patterns with a forward slash / to specify a directory.
You can negate a pattern by starting it with an exclamation point !.
By default, the following paths and files are ignored, so there’s no need to add them to .npmignore explicitly:.*.swp
._*
.DS_Store
.git
.hg
.npmrc
.lock-wscript
.svn
.wafpickle-*
config.gypi
CVS
npm-debug.log
Additionally, everything in node_modules is ignored, except for bundled dependencies. npm automatically handles this for you, so don’t bother adding node_modules to .npmignore.The following paths and files are never ignored, so adding them to .npmignore is pointless:
package.json README (and its variants) CHANGELOG (and its variants) LICENSE / LICENCE
If, given the structure of your project, you find .npmignore to be a maintenance headache, you might instead try populating the files property of package.json, which is an array of file or directory names that should be included in your package. Sometimes a whitelist is easier to manage than a blacklist.Testing whether your .npmignore or files config works§
If you want to double check that your package will include only the files you intend it to when published, you can run the npm pack command locally which will generate a tarball in the working directory, the same way it does for publishing.
因为要用到server.https 参考: https://nuxtjs.org/api/configuration-server/#example-using-https-configuration。
原文:https://www.cnblogs.com/dzkjz/p/13326877.html