use nuxtAppDir

This commit is contained in:
Pooya Parsa 2017-06-16 17:34:42 +04:30
parent 45485f5b8a
commit 8f2945111a
4 changed files with 8 additions and 9 deletions

View File

@ -14,14 +14,13 @@ require('source-map-support').install();
const Core = require('./dist/core.js')
// ------------------------------------------------------------------
// Use special env flag to specify app dir without modify builder
if (!process.env.NUXT_APP_DIR) {
process.env.NUXT_APP_DIR = path.resolve(__dirname, 'app')
}
// Polyfill Builder into Core
const Builder = require('./dist/builder')
// Use special env flag to specify app dir without modify builder
if (!process.env.NUXT_APP_TEMPALTE_DIR) {
process.env.NUXT_APP_TEMPALTE_DIR = path.resolve(__dirname, 'app')
}
Object.assign(Core, Builder)
// ------------------------------------------------------------------
module.exports = Core.default ? Core.default : Core

View File

@ -165,7 +165,7 @@ export default class Builder extends Tapable {
if (!templateVars.layouts.default) {
await mkdirp(r(this.options.buildDir, 'layouts'))
templatesFiles.push('layouts/default.vue')
templateVars.layouts.default = r(__dirname, 'app', 'layouts', 'default.vue')
templateVars.layouts.default = r(this.options.nuxtAppDir, 'layouts', 'default.vue')
}
// -- Routes --
@ -205,7 +205,7 @@ export default class Builder extends Tapable {
return {
src: customFileExists
? customPath
: r(__dirname, '../app', file), // Relative to dist
: r(this.options.nuxtAppDir, file),
dst: file,
custom: customFileExists
}

View File

@ -57,6 +57,7 @@ const defaultOptions = {
dev: (process.env.NODE_ENV !== 'production'),
runBuild: false,
buildDir: '.nuxt',
nuxtAppDir: process.env.NUXT_APP_DIR || resolve(__dirname, '../app'), // relative to dist
build: {
analyze: false,
extractCSS: false,

View File

@ -106,7 +106,6 @@ test.after('Closing server and nuxt.js', t => {
})
test.after('Should be able to start Nuxt with build done', async t => {
const Nuxt = require('../')
const rootDir = resolve(__dirname, 'fixtures/with-config')
let config = require(resolve(rootDir, 'nuxt.config.js'))
config.rootDir = rootDir