All Projects → mrTimofey → vue-ssr-starter

mrTimofey / vue-ssr-starter

Licence: other
Starter kit for projects with Webpack 4, Vue 2 and SSR

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects
CSS
56736 projects
Dockerfile
14818 projects
HTML
75241 projects

Projects that are alternatives of or similar to vue-ssr-starter

jooger.me
👍 My personal website,powered by @nuxt
Stars: ✭ 39 (-26.42%)
Mutual labels:  ssr, axios, server-side-rendering, vue-router
Egg Vue Webpack Boilerplate
Egg Vue Server Side Render (SSR) / Client Side Render (CSR)
Stars: ✭ 1,302 (+2356.6%)
Mutual labels:  ssr, axios, server-side-rendering, vue-router
Naice Blog
😺 新的博客上线啦
Stars: ✭ 93 (+75.47%)
Mutual labels:  ssr, axios, vue-router
Mmf Blog Vue2 Ssr
mmf-blog-vue2 ssr(The service side rendering)
Stars: ✭ 174 (+228.3%)
Mutual labels:  ssr, server-side-rendering, vue-router
React Use Api
Async HTTP request data for axios. Designed for diverse UI states, SSR and data pre-caching.
Stars: ✭ 49 (-7.55%)
Mutual labels:  ssr, axios, server-side-rendering
Blog Frontend Project
Web frontend code for my blogs, develop with Vue.
Stars: ✭ 206 (+288.68%)
Mutual labels:  ssr, axios, server-side-rendering
vue-element-admin
Vuejs实例-Vuejs2.0全家桶结合ELementUI制作后台管理系统http://www.cnblogs.com/weiqinl/p/6873761.html
Stars: ✭ 97 (+83.02%)
Mutual labels:  axios, vue-router
webpack-isomorphic-compiler
A compiler that makes your life easier if you are building isomorphic webpack powered apps, that is, single page applications with server-side rendering
Stars: ✭ 16 (-69.81%)
Mutual labels:  ssr, server-side-rendering
vue-bootstrap-boilerplate
📦 Vue 2/3, Bootstrap 5, Vuex, Vue-Router, Sass/Scss, ESLint, Axios (switch to vue3 branch)
Stars: ✭ 86 (+62.26%)
Mutual labels:  pug, vue-router
music
🎵vue 像素级还原mac客户端网易云音乐
Stars: ✭ 34 (-35.85%)
Mutual labels:  axios, vue-router
isomorphic-react-redux-saga-ssr
Isomorphic, React, Redux, Saga, Server Side rendering, Hot Module Reloading, Ducks, Code Splitting
Stars: ✭ 19 (-64.15%)
Mutual labels:  ssr, server-side-rendering
vue-element-admin-ts
vue-element-admin 的 typescript 版本
Stars: ✭ 101 (+90.57%)
Mutual labels:  axios, vue-router
Code-VueWapDemo
“Vue教程--Wap端项目搭建从0到1”的源码
Stars: ✭ 19 (-64.15%)
Mutual labels:  axios, vue-router
elegant-react-ssr
Server-side rendering with create-react-app, React Router v4, Helmet, Redux, and Thunk boilerplate, without ejecting CRA
Stars: ✭ 16 (-69.81%)
Mutual labels:  ssr, server-side-rendering
react-coat-ssr-demo
Demo with Typescript + React + Redux for server-side-rendering (SSR)
Stars: ✭ 100 (+88.68%)
Mutual labels:  ssr, server-side-rendering
vue-iview-admin-template
Vue 2.0 admin template based on View UI
Stars: ✭ 43 (-18.87%)
Mutual labels:  axios, vue-router
Modern-Web-App
React PWA with SSR and Code splitting
Stars: ✭ 45 (-15.09%)
Mutual labels:  ssr, server-side-rendering
ssr-starter-pack
Moved to https://github.com/Brigad/ssr-starter-pack
Stars: ✭ 12 (-77.36%)
Mutual labels:  ssr, server-side-rendering
angular-pwa
Angular 13 Example Progressive Web App (PWA)
Stars: ✭ 45 (-15.09%)
Mutual labels:  ssr, server-side-rendering
vue-douban
高仿豆瓣app
Stars: ✭ 22 (-58.49%)
Mutual labels:  axios, vue-router

Webpack, Vue, SSR project template

Includes:

  • Webpack 4
  • polka web-server
  • Vue 2 with SSR, Vuex and vue-loader
  • Stylus with kouto-swiss
  • Axios
  • Pug
  • SVG sprites builder
  • ESlint with pre-push hook

Getting started

npm i

# development server on localhost:8080
npm run dev

# production build
npm run build

# production server on localhost:8080
npm start

Configuration

.env.dev contains environment variables used for local development. You can change application port, API base URL for server and client and enable/disable proxy (http-proxy-middleware).

For production builds you should provide same environment variables yourself. Alternatively you can use .env after these steps:

  1. Move dotenv from devDependencies to dependencies.
  2. Create .env file with production config.
  3. Run npm start or NODE_ENV=production node -r dotenv/config index.

API proxy

See setup-proxy.js for description.

Application structure

  • index.js - application server
  • setup-proxy.js - http-proxy-middleware setup
  • build/ - build related code
    • setup-dev-server - development server setup
    • svg-sprite - svg sprite generation script, gathers icons from src/assets/svg-icons and compiles them into src/assets/sprite.svg
    • webpack/ - webpack config, base - common, server for server with SSR, client for browser
  • dist/ - production build files
  • src/
    • assets/ - application static assets (images, fonts, icons etc.)
      • sprite.svg - generated sprites file, require('src/assets/sprite.svg') will return file contents string
      • fonts/ - guess what
      • images/ - static images (backgrounds, patterns etc.)
      • svg-icons/ - contains SVG icons for the sprite
    • entry/ - main entry points
      • app - shared between server and client, exports a factory function returning root component instance, mixes it with app.vue
      • client - client entry
      • server - server entry
    • components/ - vue components
    • pages/ - components here are implicitly attached to routes same with componets' file names (excluding leading _ in file or folder names and 404.vue which will be used as a catch-all route)
    • filters/ - vue filters registered implicitly via Vue.filter()
    • directives/ - vue directives registered implicitly via Vue.directive()
    • store/ - Vuex storage, index returns a factory function returning configured Vuex store instance
    • utils/ - common utility functions
      • index - common utility functions
      • ssr - SSR related functions and mixins
    • app.vue - application root component, implicitly mixed with entry\app
    • http - exports http client instance (Axios)
    • layout.pug - application HTML layout
    • router - exports a factory function returning vue-router instance
    • shared.styl - globally included stylus file (for variables, mixins, etc.)

SSR related component features

Every component within src/pages directory can use some special features providing full SSR support:

  • component.routePath, String - additional route suffix. Usually used to provide dynamic route segments. You can use any string allowed for the vue-router path definition. All dynamic segments are automatically mapped to component props.

  • component.routeMeta, Object - route.meta. Include statusCode here to modify an HTTP status returned with SSR. 404 route includes 404 status code by default.

  • component.prefetch({ store, props, route }), function (store - vuex store instance, props - route params, route - current route object).

    Must return a promise. Allows some async routine before actual application rendering on server side. To pass any data to component: resolve promise with needed data and add corresponding component.data fields with their initial values to prevent ...property or method not defined... error. Automatically called on client side from beforeMount and beforeRouteChange hooks as well. See src/utils/ssr mixin.

  • Boolean prefetching data field indicates when prefetch is running.

    IMPORTANT: there is no component context within prefetch function because component instance is not created yet! That means you should not try to use this.

prefetch also works on the root component (src/app.vue) with some restrictions:

  • no way to pass component data (only store can be affected).
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].