lentoo / vue-cli-ssr-example Goto Github PK
View Code? Open in Web Editor NEW基于 vue-cli3构建的一个SSR应用程序
基于 vue-cli3构建的一个SSR应用程序
请教一下~ 热更新报了如下错误:
bootstrap:1007 Uncaught RangeError: Maximum call stack size exceeded
at hotAddUpdateChunk (bootstrap:1007)
at webpackHotUpdateCallback (bootstrap:36)
at webpackHotUpdateCallback (bootstrap:37)
at webpackHotUpdateCallback (bootstrap:37)
at webpackHotUpdateCallback (bootstrap:37)
at webpackHotUpdateCallback (bootstrap:37)
at webpackHotUpdateCallback (bootstrap:37)
at webpackHotUpdateCallback (bootstrap:37)
at webpackHotUpdateCallback (bootstrap:37)
at webpackHotUpdateCallback (bootstrap:37)
npm WARN tar ENOENT: no such file or directory, open 'E:\Users\Ekols\Desktop\vue-cli-ssr-example-master\node_modules.staging\vue-6d59989b\src\platforms\weex.DS_Store'
npm ERR! Unexpected end of JSON input while parsing near '...4.0.0","css-loader":"'
npm WARN tar ENOENT: no such file or directory, lstat 'E:\Users\Ekols\Desktop\vue-cli-ssr-example-master\node_modules.staging@vue'
"build:server": "cross-env NODE_ENV=production WEBPACK_TARGET=node vue-cli-service build --mode server",
修改成以上后解决图片访问404问题
我将项目yarn build之后,生产的dist文件,用Nginx指向里面的index.html会使得ssr失效,在本地可以使用。
或者说只能使用node环境起服务么,那部署在生产环境后,我的服务对么暴露的域名和端口要怎么配置。。。
加入asyncData后,只有项目启动首次刷新时能得到数据,再次刷新就仍然会走asyncData,但是axios已经取不到数据了
路由:http://localhost:3000/list
刷新页面报以下错误:ENOENT: no such file or directory, stat '/Users/zhanghanbing/WebstormProjects/www.jiangzi.com/dist/list'
我注意到你的package.json中,为了处理win和mac在移动文件的命令的不同而写了两条命令
"build:win": "npm run build:server && move dist\\vue-ssr-server-bundle.json bundle && npm run build:client && move bundle dist\\vue-ssr-server-bundle.json && cross-env WEBPACK_TARGET=node NODE_ENV=production node ./server/ssr.js",
"build:mac": "npm run build:server && mv dist/vue-ssr-server-bundle.json bundle && npm run build:client && mv bundle dist/vue-ssr-server-bundle.json",
但实际上这个移动文件的操作可能是是没有必要的,我个人认为你这里移动文件的目的是为了避免vue-cli-service构建之前清理文件而导致丢失前面构建的结果,然而这个行为是可以关闭的,只需要在构建client时传入 --no-clean 既可以关闭。
另外,我注意到build:win和build:mac有些许的区别,build:win完成构建后会自动启动服务器,而mac不会,不知道是否为作者无意之举呢?
文档:
outputDir
当运行 vue-cli-service build 时生成的生产环境构建文件的目录。注意目标目录在构建之前会被清除 (构建时传入 --no-clean 可关闭该行为)。
现在进行到的步骤,生成build.json,通过createBundleRenderer方法打包到index.html,这里都是没有问题的,但是当我使用koa-static进行暴露dist目录的时候报错
Uncaught ReferenceError: require is not defined at Object.2c92 (es6.array.iterator":1) at a (bootstrap:63) at Module.a949 (external "vue":1) at a (bootstrap:63) at bootstrap:195 at bootstrap:195
当不使用koa-static的时候却没有问题,只是理想的dist中的资源不能访问
你好,我根据你的博客文章来改写我之前写的浏览器渲染vue的项目,但是用SSR渲染后CSS样式全部消失了,请问如何才能在SSR渲染时显示我之前写的CSS样式呢?
| Building for production...(node:6480) UnhandledPromiseRejectionWarning: Error: Server-side bundle should have one single entry file. Avoid using CommonsChunkPlugin in the server config.
at G:\Users\The Project\nodejs-vue\vue-cli-ssr-example\node_modules\vue-server-renderer\server-plugin.js:68:13
at _next1 (eval at create (G:\Users\The Project\nodejs-vue\vue-cli-ssr-example\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:8:1)
at eval (eval at create (G:\Users\The Project\nodejs-vue\vue-cli-ssr-example\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:22:1)
at callback (G:\Users\The Project\nodejs-vue\vue-cli-ssr-example\node_modules\copy-webpack-plugin\dist\index.js:77:17)
at G:\Users\The Project\nodejs-vue\vue-cli-ssr-example\node_modules\copy-webpack-plugin\dist\index.js:118:24
(node:6480) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which
was not handled with .catch(). (rejection id: 1)
(node:6480) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit c
ode.
| Building for production...
为什么运行 npm install 时 如何解决
npm WARN tar ENOENT: no such file or directory, open 'E:\Users\Ekols\Desktop\vue-cli-ssr-example-master\node_modules.staging\vue-6d59989b\src\platforms\weex.DS_Store'
npm ERR! Unexpected end of JSON input while parsing near '...4.0.0","css-loader":"'
npm WARN tar ENOENT: no such file or directory, lstat 'E:\Users\Ekols\Desktop\vue-cli-ssr-example-master\node_modules.staging@vue'
根据你的命令试,再mac上 热更新不起作用,请问下如何解决,
url: http://localhost:3000/about 不能热更新
url:http://localhost:8080/about 可以热更新
build:win脚本只能在windows系统上运行,可以提供在linux和mac上的脚本吗,我开发使用的是mac系统,从而在mac上脚本无法运行,服务器是linux系统,希望能给出能在mac和linux上运行的脚本,O(∩_∩)O谢谢!
开发环境正常的,生产环境访问会出现这样的问题
vue ssr document is not defined
webpack-contrib/mini-css-extract-plugin#90
我尝试使用里面的方案去修复但是没有成功
希望能够关注
我知道线上设置nginx可以,但是开发环境怎么设置?
return new Router({
mode: 'history',
...
Cannot GET /about
热更新为何不是按照这个思路实现 vue-hackernews-2.0
我查看了@vue/cli-service/webpack.config 的这是最终的 webpack.json
如果这样 只要调起一个端口
运行命令 npm run dev
后启动的并非 SSR 模式,运行结果和 npm run serve
并非差别,请问开发模式下的 SSR 热更新要如何实现呢。
node ./server/ssr.js 也是报错
集成vuex时,store.js里用axios异步取到的数据,数据会显示出来,查看源码看不到这些数据内容【不是F12查看】
script:
"build:win": "npm run build:server && mv dist/vue-ssr-server-bundle.json bundle && npm run build:client && mv bundle dist/vue-ssr-server-bundle.json && cross-env WEBPACK_TARGET=node NODE_ENV=production node ./server/ssr.js",
你们能运行吗,我的运行不了呢,前端访问反的Internal Server Error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.