mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Add build.plugins and fix when no component matched
This commit is contained in:
parent
06edc8029b
commit
49f67566c2
@ -49,6 +49,7 @@ export default context => {
|
||||
context.error = _app.error.bind(_app)
|
||||
|
||||
<%= (isDev ? 'const s = isDev && Date.now()' : '') %>
|
||||
let Components = getMatchedComponents(context.route)
|
||||
<% if (store) { %>
|
||||
let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context), 'redirect', 'error')) : null)
|
||||
if (!(promise instanceof Promise)) promise = Promise.resolve()
|
||||
@ -58,12 +59,6 @@ export default context => {
|
||||
return promise
|
||||
.then(() => {
|
||||
// Call data & fecth hooks on components matched by the route.
|
||||
let Components = getMatchedComponents(context.route)
|
||||
if (!Components.length) {
|
||||
context.nuxt.error = _app.error({ statusCode: 404, message: 'This page could not be found.', url: context.route.path })
|
||||
<%= (store ? 'context.nuxt.state = store.state' : '') %>
|
||||
return Promise.resolve(_app)
|
||||
}
|
||||
return Promise.all(Components.map((Component) => {
|
||||
let promises = []
|
||||
if (!Component.options) {
|
||||
@ -89,6 +84,11 @@ export default context => {
|
||||
}))
|
||||
})
|
||||
.then((res) => {
|
||||
if (!Components.length) {
|
||||
context.nuxt.error = _app.error({ statusCode: 404, message: 'This page could not be found.', url: context.route.path })
|
||||
<%= (store ? 'context.nuxt.state = store.state' : '') %>
|
||||
return _app
|
||||
}
|
||||
<% if (isDev) { %>
|
||||
debug('Data fetching ' + context.req.url + ': ' + (Date.now() - s) + 'ms')
|
||||
<% } %>
|
||||
|
@ -30,11 +30,12 @@ const defaults = {
|
||||
app: 'nuxt.bundle.js'
|
||||
},
|
||||
vendor: [],
|
||||
loaders: []
|
||||
loaders: [],
|
||||
plugins: []
|
||||
}
|
||||
const defaultsLoaders = [
|
||||
{
|
||||
test: /\.(png|jpg|gif|svg)$/,
|
||||
test: /\.(png|jpe?g|gif|svg)$/,
|
||||
loader: 'url-loader',
|
||||
query: {
|
||||
limit: 1000, // 1KO
|
||||
|
@ -61,7 +61,8 @@ module.exports = function () {
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
plugins: this.options.build.plugins
|
||||
}
|
||||
// Add nuxt build loaders (can be configured in nuxt.config.js)
|
||||
config.module.rules = config.module.rules.concat(this.options.build.loaders)
|
||||
|
@ -23,13 +23,13 @@ module.exports = function () {
|
||||
filename: 'server-bundle.js',
|
||||
libraryTarget: 'commonjs2'
|
||||
}),
|
||||
plugins: [
|
||||
plugins: (config.plugins || []).concat([
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify(this.dev ? 'development' : 'production'),
|
||||
'process.env.VUE_ENV': '"server"',
|
||||
'process.BROWSER': false
|
||||
})
|
||||
]
|
||||
])
|
||||
})
|
||||
|
||||
// Externals
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nuxt",
|
||||
"version": "0.4.6",
|
||||
"version": "0.4.7",
|
||||
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
|
Loading…
Reference in New Issue
Block a user