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

small tweaks

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