From 5ad640b294abe550e1227ab964192ca8ad3379b6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 20 Jun 2017 16:42:21 +0430 Subject: [PATCH] use nuxt.js build target --- index.js | 8 +------- lib/core/nuxt.js | 10 +++++----- lib/index.js | 4 ++++ package.json | 8 ++++---- rollup.config.js | 4 ++++ 5 files changed, 18 insertions(+), 16 deletions(-) create mode 100755 lib/index.js diff --git a/index.js b/index.js index a76dbcf80a..c3cdb2cec0 100644 --- a/index.js +++ b/index.js @@ -13,10 +13,4 @@ require('source-map-support').install(); /* istanbul ignore else */ process.noDeprecation = true -// Require Core -const Core = require('./dist/core.js') -Object.assign(exports, Core) - -// Require Builder -const Builder = require('./dist/builder.js') -Object.assign(exports, Builder) +module.exports = require('./dist/nuxt') diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index 6d56f5c8fe..482c96b210 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -56,13 +56,13 @@ export default class Nuxt extends Tapable { console.log('\n' + chalk.bold(chalk.bgBlue.black(' OPEN ') + chalk.blue(` http://${_host}:${port}\n`))) // Close server on nuxt close - this.plugin('close', () => new Promise((_resolve, _reject) => { - server.close(_err => { + this.plugin('close', () => new Promise((resolve, reject) => { + server.close(err => { debug('server closed') - if (_err) { - return _reject(err) + if (err) { + return reject(err) } - _resolve() + resolve() }) })) diff --git a/lib/index.js b/lib/index.js new file mode 100755 index 0000000000..bb877e8e7c --- /dev/null +++ b/lib/index.js @@ -0,0 +1,4 @@ +import core from './core' +import builder from './builder' + +export default Object.assign({}, core, builder) diff --git a/package.json b/package.json index c7cb03e8d8..73aca5455e 100644 --- a/package.json +++ b/package.json @@ -48,14 +48,14 @@ ] }, "scripts": { - "test": "npm run lint && cross-env NODE_ENV=test npm run build && nyc ava --verbose --serial test/ -- && nyc report --reporter=html", + "test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", "lint": "eslint --ext .js,.vue bin lib pages test/*.js --ignore-pattern app", - "build": "rimraf dist/ && npm run build:core && npm run build:builder", + "build": "rimraf dist/ && npm run build:nuxt && npm run build:core && npm run build:builder", + "build:nuxt": "rollup -c rollup.config.js --environment TARGET:nuxt", "build:core": "rollup -c rollup.config.js --environment TARGET:core", - "watch": "npm run build:core -- -w", "build:builder": "rollup -c rollup.config.js --environment TARGET:builder", - "watch:builder": "npm run build:builder -- -w", + "watch": "npm run build:nuxt -- -w", "precommit": "npm run lint", "prepublish": "npm run build", "postinstall": "opencollective postinstall" diff --git a/rollup.config.js b/rollup.config.js index ca5a74c683..859ef6c6e8 100755 --- a/rollup.config.js +++ b/rollup.config.js @@ -38,6 +38,10 @@ const aliases = { // Builds // ----------------------------- const builds = { + nuxt: { + entry: resolve(libDir, 'index.js'), + dest: resolve(distDir, 'nuxt.js') + }, core: { entry: resolve(libDir, 'core/index.js'), dest: resolve(distDir, 'core.js')