Includes:
- Webpack 2
- Buble
- Vue 2 with SSR, Vuex and vue-loader
- Stylus with kouto-swiss
- Axios
- Pug
- SVG sprites builder
index.js
- application serverassets/
- application static assets (images, fonts, icons etc.)sprite.svg
- generated sprites file,require('assets/sprite.svg')
will return file contents stringdocs/
- downloadable static contentfonts/
- guess whati/
- static images (backgrounds, patterns etc.)icons/
- contains SVG icons for the sprite
build/
- code related to project buildingsetup-dev-server
- development server setup with hot reloadingsvg-sprite
- svg sprite generation script, gathers icons fromassets/icons
and compiles them intoassets/sprite.svg
webpack/
- webpack config,base
- common,server
for server with SSR,client
for browser
dist/
- production build filessrc/
entry/
- main entry pointsapp
- shared between server and client, exports a factory function returning root component instance, mixes it withapp.vue
client
- client entryserver
- server entry
components/
- vue componentsshared/
- comonents registered implicitly viaVue.component()
pages/
- components here are implicitly attached to routes same with componets` file names (excluding leading_
in file or folder names and404.vue
which will be used as a catch-all route)filters/
- vue filters registered implicitly viaVue.filter()
directives/
- vue directives registered implicitly viaVue.directive()
mixins/
- vue mixinsstore/
- Vuex storage,index
returns a factory function returning configured Vuex store instanceapp.vue
- aplication root component, implicitly mixed withentry\app
http
- exports http client instance (Axios)layout.pug
- application HTML layoutrouter
- exports a factory function returning vue-router instancevars.styl
- globally included stylus file (for variables, mixins, etc.)
# development server on localhost:8080
npm run dev
# production build
npm run build
# production server on localhost:8080
npm start
Every component within src/pages
directory can use some special features providing full SSR support:
-
component.routeParams
, 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 componentprops
. -
component.routeMeta
, Object -route.meta
. IncludestatusCode
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 frombeforeMount
andbeforeRouteChange
hooks as well. Seesrc/mixins/prefetch
mixin.IMPORTANT: there is no component context within
prefetch
function because component instance is not created yet!
prefetch
also works on the root component (src/app.vue
) with some restrictions:
- no
props
field in the argument; - no way to pass component data (only store can be affected).
Root application component (app.vue
) has a serverPrefetched
property.
It is always set to true
on client side and after all prefetching is done on server side.
It is not reactive until you explicitly declare it in component`s data.
- SSR configurable cache
- basic Nginx + Phusion Passenger configuration example