Cleaner structure

This commit is contained in:
Pooya Parsa 2017-06-18 12:06:00 +04:30
parent c25409ff70
commit 766009dbba
34 changed files with 21 additions and 27 deletions

View File

@ -12,15 +12,15 @@ process.noDeprecation = true
// https://github.com/evanw/node-source-map-support
require('source-map-support').install();
// Require Core
const Core = require('./dist/core.js')
Object.assign(exports, Core.default || Core)
// Require Builder
const Builder = require('./dist/builder')
Object.assign(exports, Builder.default || Builder)
// 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')
process.env.NUXT_APP_DIR = path.resolve(__dirname, 'lib/app')
}
// Polyfill Builder into Core
const Builder = require('./dist/builder')
Object.assign(Core, Builder)
module.exports = Core.default ? Core.default : Core

View File

@ -57,7 +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
nuxtAppDir: process.env.NUXT_APP_DIR || resolve(__dirname, '../lib/app'), // Relative to dist
build: {
analyze: false,
extractCSS: false,

View File

@ -42,19 +42,14 @@
"bin": {
"nuxt": "./bin/nuxt"
},
"nyc": {
"include": [
"src/**"
]
},
"scripts": {
"test": "npm run lint && nyc ava --verbose --serial test/",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"lint": "eslint --ext .js,.vue bin lib pages test/*.js --ignore-pattern lib/app",
"lint": "eslint --ext .js,.vue bin lib pages test/*.js --ignore-pattern app",
"build": "npm run build:core && npm run build:builder",
"build:core": "rollup -c build/rollup.config.js --environment TARGET:core",
"build:core": "rollup -c rollup.config.js --environment TARGET:core",
"watch": "npm run build:core -- -w",
"build:builder": "rollup -c build/rollup.config.js --environment TARGET:builder",
"build:builder": "rollup -c rollup.config.js --environment TARGET:builder",
"watch:builder": "npm run build:builder -- -w",
"precommit": "npm run lint",
"prepublish": "npm run build",

View File

@ -5,7 +5,7 @@ const rollupAlias = require('rollup-plugin-alias')
const rollupCommonJS = require('rollup-plugin-commonjs')
const rollupReplace = require('rollup-plugin-replace')
const rollupResolve = require('rollup-plugin-node-resolve')
const packageJson = require('../package.json')
const packageJson = require('./package.json')
const dependencies = Object.keys(packageJson.dependencies)
const version = packageJson.version || process.env.VERSION
@ -19,20 +19,19 @@ const banner =
' * Released under the MIT License.\n' +
' */'
// -----------------------------
// Aliases
// -----------------------------
const rootDir = resolve(__dirname, '..')
const srcDir = resolve(rootDir, 'src')
const rootDir = resolve(__dirname)
const libDir = resolve(rootDir, 'lib')
const distDir = resolve(rootDir, 'dist')
const aliases = {
core: resolve(srcDir, 'core/index.js'),
builder: resolve(srcDir, 'builder/index.js'),
common: resolve(srcDir, 'common/index.js'),
utils: resolve(srcDir, 'common/utils.js'),
app: resolve(srcDir, 'app'),
core: resolve(libDir, 'core/index.js'),
builder: resolve(libDir, 'builder/index.js'),
common: resolve(libDir, 'common/index.js'),
utils: resolve(libDir, 'common/utils.js'),
app: resolve(libDir, 'app'),
}
// -----------------------------
@ -40,11 +39,11 @@ const aliases = {
// -----------------------------
const builds = {
core: {
entry: resolve(srcDir, 'core/index.js'),
entry: resolve(libDir, 'core/index.js'),
dest: resolve(distDir, 'core.js')
},
builder: {
entry: resolve(srcDir, 'builder/index.js'),
entry: resolve(libDir, 'builder/index.js'),
dest: resolve(distDir, 'builder.js')
}
}