Commit 0253ebcc authored by Evan You's avatar Evan You

small tweaks

parent ad310a94
const path = require('path')
const webpack = require('webpack')
const vueConfig = require('./vue-loader.config')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
......@@ -48,7 +49,7 @@ module.exports = {
maxEntrypointSize: 300000,
hints: isProd ? 'warning' : false
},
plugins: isProd ? [] : [
new FriendlyErrorsPlugin()
]
plugins: isProd
? [new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false }})]
: [new FriendlyErrorsPlugin()]
}
......@@ -39,12 +39,6 @@ const config = merge(base, {
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
// minify JS
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
// auto generate service worker
new SWPrecachePlugin({
cacheId: 'vue-hn',
......
......@@ -9,7 +9,7 @@ Vue.mixin({
if (fetchData) {
this.dataPromise = fetchData(
this.$store,
this.$route.params
this.$route
)
}
}
......
......@@ -8,11 +8,10 @@ const isDev = process.env.NODE_ENV !== 'production'
// Since data fetching is async, this function is expected to
// return a Promise that resolves to the app instance.
export default context => {
return new Promise((resolve, reject) => {
const s = isDev && Date.now()
const { app, router, store } = createApp()
return new Promise((resolve, reject) => {
// set router's location
router.push(context.url)
......@@ -30,7 +29,7 @@ export default context => {
Promise.all(matchedComponents.map(component => {
return component.fetchData && component.fetchData(
store,
router.currentRoute.params,
router.currentRoute,
context
)
})).then(() => {
......@@ -44,6 +43,6 @@ export default context => {
context.state = store.state
resolve(app)
}).catch(reject)
})
}, reject)
})
}
......@@ -10,7 +10,7 @@ export default function createListView (type) {
return {
name: `${type}-stories-view`,
fetchData (store, params, context) {
fetchData (store, route, context) {
return store.dispatch('FETCH_LIST_DATA', { type }).then(() => {
setTitle(camelize(type), context)
})
......
......@@ -46,9 +46,9 @@ export default {
}
},
fetchData (store, params, context) {
return store.dispatch('FETCH_ITEMS', { ids: [params.id] }).then(() => {
const item = store.state.items[params.id]
fetchData (store, { params: { id }}, context) {
return store.dispatch('FETCH_ITEMS', { ids: [id] }).then(() => {
const item = store.state.items[id]
setTitle(item.title, context)
})
},
......
......@@ -30,9 +30,9 @@ export default {
}
},
fetchData (store, params, context) {
return store.dispatch('FETCH_USER', { id: params.id }).then(() => {
const user = store.state.users[params.id]
fetchData (store, { params: { id }}, context) {
return store.dispatch('FETCH_USER', { id }).then(() => {
const user = store.state.users[id]
setTitle(user.id, context)
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment