From 8f2945111a2189b53419e84d18cecd790ef3bf9b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 16 Jun 2017 17:34:42 +0430 Subject: [PATCH] use nuxtAppDir --- index.js | 11 +++++------ src/builder/builder.js | 4 ++-- src/core/options.js | 1 + test/with-config.test.js | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index fa3a31ff19..b753f4c108 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/src/builder/builder.js b/src/builder/builder.js index 7667d03448..5a65c2b9d5 100644 --- a/src/builder/builder.js +++ b/src/builder/builder.js @@ -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 } diff --git a/src/core/options.js b/src/core/options.js index 42e2e5e29a..a01e346cde 100755 --- a/src/core/options.js +++ b/src/core/options.js @@ -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, diff --git a/test/with-config.test.js b/test/with-config.test.js index def656d841..ae4db48b02 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -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