A boilerplate for developing Server Side Render Vue.js Application
,: npm i
.
npm run dev
.
,,,:
npm run build && npm start # pm2, npm run pm2
service-worker(pwa)
, https
, build/webpack.client.conf.js
SWPlugin ,:
new SWPrecachePlugin({
cacheId: 'vue-ssr-justemit',
filename: 'service-worker.js',
minify: true,
// false, sw filename?hash
dontCacheBustUrlsMatching: false,
//
staticFileGlobsIgnorePatterns: [/\.map$/, /\.css$/],
// For unknown URLs, fallback to the index page
navigateFallback: 'https://example/', //
//
runtimeCaching: [ //
{
urlPattern: '/',
handler: 'networkFirst'
},
{
urlPattern: /\/(page1|page2|page3)/,
handler: 'networkFirst'
}
]
}
:
https://example.com/
, service-worker https://example.com/
, https://example.com/page1
/page1
.
: https://example.com/page1
( , entry-server
), service-worker ,.
.(:
Vue
src
components #
router # vue-router
store # vuex store
App.vue
app.js # entry(universal entry)
entry-client.js #
entry-server.js #
app.js
app.js
Vue DOMapp.js
createApp
entry-client.js
DOM
import { createApp } from './app'
const { app } = createApp()
app.$mount('#app')
entry-server.js
export default
vue-router``vuex
window
jest
vue-test-utils
vuex
store
import { createStore } from '@/store'
const store = createStore()
test('test', () => {
const wrapper = shallow(Component, { store })
})
MIT