mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Use relative path
This commit is contained in:
parent
365d51c0b7
commit
e1126d799c
@ -6,7 +6,7 @@
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
import NuxtChild from './nuxt-child'
|
||||
import NuxtError from '<%= components.ErrorPage ? components.ErrorPage : "./nuxt-error.vue" %>'
|
||||
import NuxtError from '<%= components.ErrorPage ? (components.ErrorPage.includes('~') ? components.ErrorPage : "../" + components.ErrorPage) : "./nuxt-error.vue" %>'
|
||||
|
||||
export default {
|
||||
name: 'nuxt',
|
||||
|
@ -23,7 +23,7 @@ function recursiveRoutes(routes, tab, components) {
|
||||
var _components = []
|
||||
var _routes = recursiveRoutes(router.routes, '\t\t', _components)
|
||||
uniqBy(_components, '_name').forEach((route) => { %>
|
||||
const <%= route._name %> = () => import('<%= route.component %>' /* webpackChunkName: "pages/<%= route.name %>" */)
|
||||
const <%= route._name %> = () => import('<%= relative(route.component) %>' /* webpackChunkName: "pages/<%= route.name %>" */)
|
||||
<% }) %>
|
||||
|
||||
<% if (router.scrollBehavior) { %>
|
||||
|
@ -5,7 +5,7 @@ import hash from 'hash-sum'
|
||||
import pify from 'pify'
|
||||
import webpack from 'webpack'
|
||||
import serialize from 'serialize-javascript'
|
||||
import { join, resolve, basename, dirname } from 'path'
|
||||
import { join, resolve, basename, dirname, relative } from 'path'
|
||||
import Tapable from 'tappable'
|
||||
import MFS from 'memory-fs'
|
||||
import webpackDevMiddleware from 'webpack-dev-middleware'
|
||||
@ -134,10 +134,10 @@ export default class Builder extends Tapable {
|
||||
}),
|
||||
appPath: './App.vue',
|
||||
layouts: Object.assign({}, this.options.layouts),
|
||||
loading: typeof this.options.loading === 'string' ? r(this.options.srcDir, this.options.loading) : this.options.loading,
|
||||
loading: typeof this.options.loading === 'string' ? this.relative(r(this.options.srcDir, this.options.loading)) : this.options.loading,
|
||||
transition: this.options.transition,
|
||||
components: {
|
||||
ErrorPage: this.options.ErrorPage ? r(this.options.ErrorPage) : null
|
||||
ErrorPage: this.options.ErrorPage ? this.relative(r(this.options.ErrorPage)) : null
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,17 +147,17 @@ export default class Builder extends Tapable {
|
||||
layoutsFiles.forEach((file) => {
|
||||
let name = file.split('/').slice(-1)[0].replace('.vue', '')
|
||||
if (name === 'error') return
|
||||
templateVars.layouts[name] = r(this.options.srcDir, file)
|
||||
templateVars.layouts[name] = this.relative(r(this.options.srcDir, file))
|
||||
})
|
||||
if (layoutsFiles.includes('layouts/error.vue')) {
|
||||
templateVars.components.ErrorPage = r(this.options.srcDir, 'layouts/error.vue')
|
||||
if (layoutsFiles.includes('layouts/error.vue') && !templateVars.components.ErrorPage) {
|
||||
templateVars.components.ErrorPage = this.relative(r(this.options.srcDir, 'layouts/error.vue'))
|
||||
}
|
||||
}
|
||||
// If no default layout, create its folder and add the default folder
|
||||
if (!templateVars.layouts.default) {
|
||||
await mkdirp(r(this.options.buildDir, 'layouts'))
|
||||
templatesFiles.push('layouts/default.vue')
|
||||
templateVars.layouts.default = r(this.options.nuxtAppDir, 'layouts', 'default.vue')
|
||||
templateVars.layouts.default = './layouts/default.vue'
|
||||
}
|
||||
|
||||
// -- Routes --
|
||||
@ -224,7 +224,8 @@ export default class Builder extends Tapable {
|
||||
serialize,
|
||||
hash,
|
||||
r,
|
||||
wp
|
||||
wp,
|
||||
relative: this.relative.bind(this)
|
||||
}
|
||||
})
|
||||
const content = template(Object.assign({}, templateVars, {
|
||||
@ -407,6 +408,13 @@ export default class Builder extends Tapable {
|
||||
customFilesWatcher.close()
|
||||
})
|
||||
}
|
||||
|
||||
relative(dest) {
|
||||
if (dest && dest.includes('~')) {
|
||||
return dest
|
||||
}
|
||||
return relative(this.options.buildDir, dest)
|
||||
}
|
||||
}
|
||||
|
||||
const STATUS = {
|
||||
|
Loading…
Reference in New Issue
Block a user