mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-28 22:32:42 +00:00
feat: migrate nuxt into monorepo (#4051)
Co-authored-by: Clark Du <clark.duxin@gmail.com> Co-authored-by: Pooya Parsa <pooya@pi0.ir>
This commit is contained in:
parent
e115890a94
commit
9c1e0d1743
14
.babelrc
14
.babelrc
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"test": {
|
|
||||||
"presets": [
|
|
||||||
["@babel/env", {
|
|
||||||
"targets": {
|
|
||||||
"node": "current"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
],
|
|
||||||
"plugins": ["dynamic-import-node"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,16 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
working_directory: ~/project/nuxt
|
working_directory: ~/project
|
||||||
docker:
|
docker:
|
||||||
- image: banian/node-headless-chrome
|
- image: banian/node-headless-chrome
|
||||||
|
environment:
|
||||||
|
- NODE_ENV: test
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Phase 1: Setup
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
setup:
|
setup:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
@ -19,23 +24,36 @@ jobs:
|
|||||||
# Install dependencies
|
# Install dependencies
|
||||||
- run:
|
- run:
|
||||||
name: Install Dependencies
|
name: Install Dependencies
|
||||||
command: NODE_ENV=dev yarn
|
command: yarn --frozen-lockfile --non-interactive
|
||||||
|
|
||||||
# Keep cache
|
# Link
|
||||||
|
- run:
|
||||||
|
name: Link
|
||||||
|
command: yarn lerna link
|
||||||
|
|
||||||
|
# Save cache
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: yarn-{{ checksum "yarn.lock" }}
|
key: yarn-{{ checksum "yarn.lock" }}
|
||||||
paths:
|
paths:
|
||||||
- "node_modules"
|
- node_modules
|
||||||
|
- distributions/*/node_modules
|
||||||
|
- packages/*/node_modules
|
||||||
|
|
||||||
# Persist files
|
# Persist workspace
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: ~/project
|
root: ~/project
|
||||||
paths:
|
paths:
|
||||||
- nuxt
|
- node_modules
|
||||||
|
- distributions/*/node_modules
|
||||||
|
- packages/*/node_modules
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Phase 2: Lint + Audit + Build Nuxt and fixtures
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
lint:
|
lint:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
@ -45,6 +63,7 @@ jobs:
|
|||||||
audit:
|
audit:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
@ -54,44 +73,52 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
|
- run:
|
||||||
|
name: Build Nuxt
|
||||||
|
command: yarn build
|
||||||
- run:
|
- run:
|
||||||
name: Build Fixtures
|
name: Build Fixtures
|
||||||
command: yarn build && yarn test:fixtures -w=4 --coverage && yarn coverage
|
command: yarn build && yarn test:fixtures -w=4 --coverage && yarn coverage
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: ~/project
|
root: ~/project
|
||||||
paths:
|
paths:
|
||||||
- nuxt/test/fixtures
|
- test/fixtures # TODO
|
||||||
- nuxt/dist
|
- distributions/**/dist
|
||||||
environment:
|
- packages/**/dist
|
||||||
- NODE_ENV: "test"
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Phase 3: Unit and E2E tests
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
test-unit:
|
test-unit:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
name: Unit Test
|
name: Unit Tests
|
||||||
command: yarn test:unit -w=4 --coverage && yarn coverage
|
command: yarn test:unit -w=4 --coverage && yarn coverage
|
||||||
environment:
|
|
||||||
- NODE_ENV: "test"
|
|
||||||
|
|
||||||
test-e2e:
|
test-e2e:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
name: E2E Test
|
name: E2E Tests
|
||||||
command: yarn test:e2e && yarn coverage
|
command: yarn test:e2e && yarn coverage
|
||||||
environment:
|
|
||||||
- NODE_ENV: "test"
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Phase 4: Release (dev branch only)
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
release:
|
release:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
@ -99,19 +126,14 @@ jobs:
|
|||||||
command: |
|
command: |
|
||||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||||
echo "//registry.yarnpkg.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
echo "//registry.yarnpkg.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||||
BUILD_SUFFIX=edge yarn build
|
yarn lerna version
|
||||||
npm publish
|
PACKAGE_SUFFIX=edge yarn build
|
||||||
for p in packages/*; do
|
yarn lerna publish
|
||||||
if [ -f "$p/package.json" ]; then
|
|
||||||
cd $p
|
|
||||||
npm publish
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
# Workflow definition
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
setup-and-parallel-test:
|
setup-and-test:
|
||||||
jobs:
|
jobs:
|
||||||
- setup
|
- setup
|
||||||
|
|
||||||
|
@ -5,3 +5,4 @@ dist
|
|||||||
.nuxt
|
.nuxt
|
||||||
examples/coffeescript/pages/index.vue
|
examples/coffeescript/pages/index.vue
|
||||||
!examples/storybook/.storybook
|
!examples/storybook/.storybook
|
||||||
|
coverage
|
||||||
|
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,28 +1,33 @@
|
|||||||
# Dependencies
|
# Dependencies
|
||||||
node_modules
|
node_modules
|
||||||
examples/**/*/yarn.lock
|
|
||||||
jspm_packages
|
jspm_packages
|
||||||
|
|
||||||
|
# Only keep yarn.lock in the root
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
**/yarn.lock
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
*.log
|
*.log
|
||||||
npm-debug.log*
|
|
||||||
yarn-error.log*
|
# Packages
|
||||||
|
packages/*/LICENSE
|
||||||
|
|
||||||
|
# Distributions
|
||||||
|
distributions/*/LICENSE
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
.nuxt*
|
.nuxt*
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
# Dist folder
|
# Dist folders
|
||||||
dist
|
dist
|
||||||
|
|
||||||
# Dist example generation
|
# Coverage reports
|
||||||
examples/**/dist
|
|
||||||
|
|
||||||
# Coverage support
|
|
||||||
coverage
|
coverage
|
||||||
*.lcov
|
*.lcov
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
|
||||||
|
# VSCode
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# Intellij idea
|
# Intellij idea
|
||||||
@ -30,7 +35,7 @@ coverage
|
|||||||
.idea
|
.idea
|
||||||
|
|
||||||
# OSX
|
# OSX
|
||||||
*.DS_Store
|
.DS_Store
|
||||||
.AppleDouble
|
.AppleDouble
|
||||||
.LSOverride
|
.LSOverride
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# Test against the latest version of this Node.js version
|
# Test against the latest version of this Node.js version
|
||||||
environment:
|
environment:
|
||||||
nodejs_version: "Current"
|
nodejs_version: "Current"
|
||||||
# environment:
|
|
||||||
# matrix:
|
|
||||||
# - nodejs_version: "Current"
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
- 'node_modules -> yarn.lock'
|
- 'node_modules -> yarn.lock'
|
||||||
@ -17,8 +14,12 @@ shallow_clone: true
|
|||||||
install:
|
install:
|
||||||
# Get the latest stable version of Node.js or io.js
|
# Get the latest stable version of Node.js or io.js
|
||||||
- ps: Install-Product node $env:nodejs_version
|
- ps: Install-Product node $env:nodejs_version
|
||||||
# install modules
|
# Install modules
|
||||||
- yarn install
|
- yarn install
|
||||||
|
# Link dependencies
|
||||||
|
- yarn lerna link
|
||||||
|
# Build packages
|
||||||
|
- yarn build
|
||||||
|
|
||||||
# Post-install test scripts.
|
# Post-install test scripts.
|
||||||
test_script:
|
test_script:
|
||||||
|
15
babel.config.js
Normal file
15
babel.config.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
module.exports = function (api) {
|
||||||
|
if (api.env('test')) {
|
||||||
|
return {
|
||||||
|
presets: [
|
||||||
|
['@babel/env', {
|
||||||
|
targets: {
|
||||||
|
node: 'current'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
],
|
||||||
|
plugins: ['dynamic-import-node']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
}
|
@ -1,88 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
|
||||||
|
|
||||||
const parseArgs = require('minimist')
|
|
||||||
const consola = require('consola')
|
|
||||||
const { Nuxt, Builder, Generator } = require('..')
|
|
||||||
const { loadNuxtConfig } = require('./common/utils')
|
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
|
||||||
alias: {
|
|
||||||
h: 'help',
|
|
||||||
c: 'config-file',
|
|
||||||
a: 'analyze',
|
|
||||||
s: 'spa',
|
|
||||||
u: 'universal',
|
|
||||||
q: 'quiet'
|
|
||||||
},
|
|
||||||
boolean: ['h', 'a', 's', 'u', 'q'],
|
|
||||||
string: ['c'],
|
|
||||||
default: {
|
|
||||||
c: 'nuxt.config.js'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (argv.help) {
|
|
||||||
process.stderr.write(`
|
|
||||||
Description
|
|
||||||
Compiles the application for production deployment
|
|
||||||
Usage
|
|
||||||
$ nuxt build <dir>
|
|
||||||
Options
|
|
||||||
--analyze, -a Launch webpack-bundle-analyzer to optimize your bundles.
|
|
||||||
--spa, -s Launch in SPA mode
|
|
||||||
--universal, -u Launch in Universal mode (default)
|
|
||||||
--no-generate Don't generate static version for SPA mode (useful for nuxt start)
|
|
||||||
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
|
||||||
--quiet, -q Disable output except for errors
|
|
||||||
--help, -h Displays this message
|
|
||||||
`)
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = loadNuxtConfig(argv)
|
|
||||||
|
|
||||||
// Create production build when calling `nuxt build`
|
|
||||||
options.dev = false
|
|
||||||
|
|
||||||
// Analyze option
|
|
||||||
options.build = options.build || {}
|
|
||||||
if (argv.analyze && typeof options.build.analyze !== 'object') {
|
|
||||||
options.build.analyze = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Silence output when using --quiet
|
|
||||||
if (argv.quiet) {
|
|
||||||
options.build.quiet = !!argv.quiet
|
|
||||||
}
|
|
||||||
|
|
||||||
const nuxt = new Nuxt(options)
|
|
||||||
const builder = new Builder(nuxt)
|
|
||||||
|
|
||||||
// Setup hooks
|
|
||||||
nuxt.hook('error', err => consola.fatal(err))
|
|
||||||
|
|
||||||
// Close function
|
|
||||||
const close = () => {
|
|
||||||
// In analyze mode wait for plugin
|
|
||||||
// emitting assets and opening browser
|
|
||||||
if (options.build.analyze === true || typeof options.build.analyze === 'object') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.mode !== 'spa' || argv.generate === false) {
|
|
||||||
// Build only
|
|
||||||
builder
|
|
||||||
.build()
|
|
||||||
.then(close)
|
|
||||||
.catch(err => consola.fatal(err))
|
|
||||||
} else {
|
|
||||||
// Build + Generate for static deployment
|
|
||||||
new Generator(nuxt, builder)
|
|
||||||
.generate({ build: true })
|
|
||||||
.then(close)
|
|
||||||
.catch(err => consola.fatal(err))
|
|
||||||
}
|
|
100
bin/nuxt-dev
100
bin/nuxt-dev
@ -1,100 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
|
||||||
|
|
||||||
const parseArgs = require('minimist')
|
|
||||||
const consola = require('consola')
|
|
||||||
const { version } = require('../package.json')
|
|
||||||
const { Nuxt, Builder } = require('..')
|
|
||||||
const { loadNuxtConfig } = require('./common/utils')
|
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
|
||||||
alias: {
|
|
||||||
h: 'help',
|
|
||||||
H: 'hostname',
|
|
||||||
p: 'port',
|
|
||||||
c: 'config-file',
|
|
||||||
s: 'spa',
|
|
||||||
u: 'universal',
|
|
||||||
v: 'version'
|
|
||||||
},
|
|
||||||
boolean: ['h', 's', 'u', 'v'],
|
|
||||||
string: ['H', 'c'],
|
|
||||||
default: {
|
|
||||||
c: 'nuxt.config.js'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (argv.version) {
|
|
||||||
process.stderr.write(version + '\n')
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv.hostname === '') {
|
|
||||||
consola.fatal('Provided hostname argument has no value')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv.help) {
|
|
||||||
process.stderr.write(`
|
|
||||||
Description
|
|
||||||
Starts the application in development mode (hot-code reloading, error
|
|
||||||
reporting, etc)
|
|
||||||
Usage
|
|
||||||
$ nuxt dev <dir> -p <port number> -H <hostname>
|
|
||||||
Options
|
|
||||||
--port, -p A port number on which to start the application
|
|
||||||
--hostname, -H Hostname on which to start the application
|
|
||||||
--spa Launch in SPA mode
|
|
||||||
--universal Launch in Universal mode (default)
|
|
||||||
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
|
||||||
--help, -h Displays this message
|
|
||||||
`)
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = () => {
|
|
||||||
// Force development mode for add hot reloading and watching changes
|
|
||||||
return Object.assign(loadNuxtConfig(argv), { dev: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
const errorHandler = (err, instance) => {
|
|
||||||
instance && instance.builder.watchServer()
|
|
||||||
consola.error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start dev
|
|
||||||
(function startDev(oldInstance) {
|
|
||||||
let nuxt, builder
|
|
||||||
|
|
||||||
try {
|
|
||||||
nuxt = new Nuxt(config())
|
|
||||||
builder = new Builder(nuxt)
|
|
||||||
nuxt.hook('watch:fileChanged', (builder, fname) => {
|
|
||||||
consola.debug(`[${fname}] changed, Rebuilding the app...`)
|
|
||||||
startDev({ nuxt: builder.nuxt, builder })
|
|
||||||
})
|
|
||||||
} catch (err) {
|
|
||||||
return errorHandler(err, oldInstance)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
Promise.resolve()
|
|
||||||
.then(() => oldInstance && oldInstance.nuxt.clearHook('watch:fileChanged'))
|
|
||||||
.then(() => oldInstance && oldInstance.builder.unwatch())
|
|
||||||
// Start build
|
|
||||||
.then(() => builder.build())
|
|
||||||
// Close old nuxt no mater if build successfully
|
|
||||||
.catch((err) => {
|
|
||||||
oldInstance && oldInstance.nuxt.close()
|
|
||||||
// Jump to eventHandler
|
|
||||||
throw err
|
|
||||||
})
|
|
||||||
.then(() => oldInstance && oldInstance.nuxt.close())
|
|
||||||
// Start listening
|
|
||||||
.then(() => nuxt.listen())
|
|
||||||
// Show ready message first time, others will be shown through WebpackBar
|
|
||||||
.then(() => !oldInstance && nuxt.showReady(false))
|
|
||||||
.then(() => builder.watchServer())
|
|
||||||
// Handle errors
|
|
||||||
.catch(err => errorHandler(err, { builder, nuxt }))
|
|
||||||
)
|
|
||||||
})()
|
|
@ -1,58 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
|
||||||
|
|
||||||
const parseArgs = require('minimist')
|
|
||||||
const consola = require('consola')
|
|
||||||
const { Nuxt, Builder, Generator } = require('..')
|
|
||||||
const { loadNuxtConfig } = require('./common/utils')
|
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
|
||||||
alias: {
|
|
||||||
h: 'help',
|
|
||||||
c: 'config-file',
|
|
||||||
s: 'spa',
|
|
||||||
u: 'universal'
|
|
||||||
},
|
|
||||||
boolean: ['h', 's', 'u', 'build'],
|
|
||||||
string: ['c'],
|
|
||||||
default: {
|
|
||||||
c: 'nuxt.config.js',
|
|
||||||
build: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (argv.help) {
|
|
||||||
process.stderr.write(`
|
|
||||||
Description
|
|
||||||
Generate a static web application (server-rendered)
|
|
||||||
Usage
|
|
||||||
$ nuxt generate <dir>
|
|
||||||
Options
|
|
||||||
--spa Launch in SPA mode
|
|
||||||
--universal Launch in Universal mode (default)
|
|
||||||
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
|
||||||
--help, -h Displays this message
|
|
||||||
--no-build Just run generate for faster builds when just dynamic routes changed. Nuxt build is needed before this command.
|
|
||||||
`)
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = loadNuxtConfig(argv)
|
|
||||||
|
|
||||||
options.dev = false // Force production mode (no webpack middleware called)
|
|
||||||
|
|
||||||
const nuxt = new Nuxt(options)
|
|
||||||
const builder = new Builder(nuxt)
|
|
||||||
const generator = new Generator(nuxt, builder)
|
|
||||||
|
|
||||||
const generateOptions = {
|
|
||||||
init: true,
|
|
||||||
build: argv.build
|
|
||||||
}
|
|
||||||
|
|
||||||
generator
|
|
||||||
.generate(generateOptions)
|
|
||||||
.then(() => {
|
|
||||||
process.exit(0)
|
|
||||||
})
|
|
||||||
.catch(err => consola.fatal(err))
|
|
@ -1,86 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
|
||||||
|
|
||||||
const fs = require('fs')
|
|
||||||
const { resolve } = require('path')
|
|
||||||
const parseArgs = require('minimist')
|
|
||||||
const consola = require('consola')
|
|
||||||
const { Nuxt } = require('../dist/nuxt-start')
|
|
||||||
const { loadNuxtConfig } = require('./common/utils')
|
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
|
||||||
alias: {
|
|
||||||
h: 'help',
|
|
||||||
H: 'hostname',
|
|
||||||
p: 'port',
|
|
||||||
n: 'unix-socket',
|
|
||||||
c: 'config-file',
|
|
||||||
s: 'spa',
|
|
||||||
u: 'universal'
|
|
||||||
},
|
|
||||||
boolean: ['h', 's', 'u'],
|
|
||||||
string: ['H', 'c', 'n'],
|
|
||||||
default: {
|
|
||||||
c: 'nuxt.config.js'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (argv.hostname === '') {
|
|
||||||
consola.fatal('Provided hostname argument has no value')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv.help) {
|
|
||||||
process.stderr.write(`
|
|
||||||
Description
|
|
||||||
Starts the application in production mode.
|
|
||||||
The application should be compiled with \`nuxt build\` first.
|
|
||||||
Usage
|
|
||||||
$ nuxt start <dir> -p <port number> -H <hostname>
|
|
||||||
Options
|
|
||||||
--port, -p A port number on which to start the application
|
|
||||||
--hostname, -H Hostname on which to start the application
|
|
||||||
--unix-socket, -n Path to a UNIX socket
|
|
||||||
--spa Launch in SPA mode
|
|
||||||
--universal Launch in Universal mode (default)
|
|
||||||
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
|
||||||
--help, -h Displays this message
|
|
||||||
`)
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = loadNuxtConfig(argv)
|
|
||||||
|
|
||||||
// Force production mode (no webpack middleware called)
|
|
||||||
options.dev = false
|
|
||||||
|
|
||||||
const nuxt = new Nuxt(options)
|
|
||||||
|
|
||||||
// Setup hooks
|
|
||||||
nuxt.hook('error', err => consola.fatal(err))
|
|
||||||
|
|
||||||
// Check if project is built for production
|
|
||||||
const distDir = resolve(
|
|
||||||
nuxt.options.rootDir,
|
|
||||||
nuxt.options.buildDir || '.nuxt',
|
|
||||||
'dist',
|
|
||||||
'server'
|
|
||||||
)
|
|
||||||
if (!fs.existsSync(distDir)) {
|
|
||||||
consola.fatal(
|
|
||||||
'No build files found, please run `nuxt build` before launching `nuxt start`'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if SSR Bundle is required
|
|
||||||
if (nuxt.options.render.ssr === true) {
|
|
||||||
const ssrBundlePath = resolve(distDir, 'server-bundle.json')
|
|
||||||
if (!fs.existsSync(ssrBundlePath)) {
|
|
||||||
consola.fatal(
|
|
||||||
'No SSR build! Please start with `nuxt start --spa` or build using `nuxt build --universal`'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nuxt.listen().then(() => {
|
|
||||||
nuxt.showReady(false)
|
|
||||||
})
|
|
11
distributions/nuxt-legacy/CHANGELOG.md
Normal file
11
distributions/nuxt-legacy/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# 2.3.0 (2018-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Migrate Nuxt into monorepo
|
27
distributions/nuxt-legacy/bin/nuxt-legacy.js
Executable file
27
distributions/nuxt-legacy/bin/nuxt-legacy.js
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const register = require('@babel/register')
|
||||||
|
|
||||||
|
require('@babel/polyfill')
|
||||||
|
|
||||||
|
register({
|
||||||
|
presets: [
|
||||||
|
[ '@babel/env', { targets: { node: 'current' } } ]
|
||||||
|
],
|
||||||
|
ignore: [
|
||||||
|
(path) => {
|
||||||
|
// Transpile known packages
|
||||||
|
if (/(@nuxt|@nuxtjs)[\\/]/.test(path)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// Ignore everything else inside node_modules
|
||||||
|
if (/node_modules/.test(path)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// Transpile project files
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
require('@nuxt/cli/bin/nuxt.js')
|
23
distributions/nuxt-legacy/package.js
Normal file
23
distributions/nuxt-legacy/package.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export default {
|
||||||
|
build: false,
|
||||||
|
extend(pkg, { load }) {
|
||||||
|
pkg.on('build:done', () => {
|
||||||
|
const mono = load('../..')
|
||||||
|
const nuxt = load('../nuxt')
|
||||||
|
|
||||||
|
pkg.copyFilesFrom(mono, [
|
||||||
|
'LICENSE'
|
||||||
|
])
|
||||||
|
|
||||||
|
pkg.copyFieldsFrom(nuxt, [
|
||||||
|
'license',
|
||||||
|
'repository',
|
||||||
|
'contributors',
|
||||||
|
'keywords',
|
||||||
|
'collective'
|
||||||
|
])
|
||||||
|
|
||||||
|
pkg.writePackage()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
67
distributions/nuxt-legacy/package.json
Normal file
67
distributions/nuxt-legacy/package.json
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
{
|
||||||
|
"name": "nuxt-legacy",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"description": "Legacy build of Nuxt.js for Node.js < 8.0.0",
|
||||||
|
"keywords": [
|
||||||
|
"nuxt",
|
||||||
|
"nuxt.js",
|
||||||
|
"nuxtjs",
|
||||||
|
"ssr",
|
||||||
|
"vue",
|
||||||
|
"vue isomorphic",
|
||||||
|
"vue server side",
|
||||||
|
"vue ssr",
|
||||||
|
"vue universal",
|
||||||
|
"vue versatile",
|
||||||
|
"vue.js",
|
||||||
|
"vuejs"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/nuxt/nuxt.js#readme",
|
||||||
|
"repository": "nuxt/nuxt.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Sebastien Chopin (@Atinux)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexandre Chopin (@alexchopin)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Pooya Parsa (@pi0)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Clark Du (@clarkdo)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jonas Galvez (@galvez)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexander Lichter (@manniL}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"bin"
|
||||||
|
],
|
||||||
|
"bin": {
|
||||||
|
"nuxt-legacy": "bin/nuxt-legacy.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/core": "^7.1.2",
|
||||||
|
"@babel/polyfill": "^7.0.0",
|
||||||
|
"@babel/preset-env": "^7.1.0",
|
||||||
|
"@babel/register": "^7.0.0",
|
||||||
|
"@nuxt/builder": "^2.3.0",
|
||||||
|
"@nuxt/cli": "^2.3.0",
|
||||||
|
"@nuxt/common": "^2.3.0",
|
||||||
|
"@nuxt/core": "^2.3.0",
|
||||||
|
"consola": "^1.4.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0",
|
||||||
|
"npm": ">=3.0.0"
|
||||||
|
},
|
||||||
|
"collective": {
|
||||||
|
"url": "https://opencollective.com/nuxtjs",
|
||||||
|
"logoUrl": "https://opencollective.com/nuxtjs/logo.txt?reverse=true&variant=variant2"
|
||||||
|
}
|
||||||
|
}
|
11
distributions/nuxt-start/CHANGELOG.md
Normal file
11
distributions/nuxt-start/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# 2.3.0 (2018-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Migrate Nuxt into monorepo
|
23
distributions/nuxt-start/package.js
Normal file
23
distributions/nuxt-start/package.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export default {
|
||||||
|
build: true,
|
||||||
|
extend(pkg, { load }) {
|
||||||
|
pkg.on('build:done', () => {
|
||||||
|
const mono = load('../..')
|
||||||
|
const nuxt = load('../nuxt')
|
||||||
|
|
||||||
|
pkg.copyFilesFrom(mono, [
|
||||||
|
'LICENSE'
|
||||||
|
])
|
||||||
|
|
||||||
|
pkg.copyFieldsFrom(nuxt, [
|
||||||
|
'license',
|
||||||
|
'repository',
|
||||||
|
'contributors',
|
||||||
|
'keywords',
|
||||||
|
'engines'
|
||||||
|
])
|
||||||
|
|
||||||
|
pkg.writePackage()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
56
distributions/nuxt-start/package.json
Normal file
56
distributions/nuxt-start/package.json
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"name": "nuxt-start",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"description": "Starts Nuxt.js Application in production mode",
|
||||||
|
"keywords": [
|
||||||
|
"nuxt",
|
||||||
|
"nuxt.js",
|
||||||
|
"nuxtjs",
|
||||||
|
"ssr",
|
||||||
|
"vue",
|
||||||
|
"vue isomorphic",
|
||||||
|
"vue server side",
|
||||||
|
"vue ssr",
|
||||||
|
"vue universal",
|
||||||
|
"vue versatile",
|
||||||
|
"vue.js",
|
||||||
|
"vuejs"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/nuxt/nuxt.js#readme",
|
||||||
|
"repository": "nuxt/nuxt.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Sebastien Chopin (@Atinux)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexandre Chopin (@alexchopin)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Pooya Parsa (@pi0)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Clark Du (@clarkdo)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jonas Galvez (@galvez)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexander Lichter (@manniL}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"main": "dist/nuxt-start.js",
|
||||||
|
"dependencies": {
|
||||||
|
"@nuxt/cli": "^2.3.0",
|
||||||
|
"@nuxt/common": "^2.3.0",
|
||||||
|
"@nuxt/core": "^2.3.0",
|
||||||
|
"consola": "^1.4.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0.0",
|
||||||
|
"npm": ">=5.0.0"
|
||||||
|
}
|
||||||
|
}
|
1
distributions/nuxt-start/src/index.js
Normal file
1
distributions/nuxt-start/src/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from '@nuxt/core'
|
11
distributions/nuxt/CHANGELOG.md
Normal file
11
distributions/nuxt/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# 2.3.0 (2018-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Migrate Nuxt into monorepo
|
12
distributions/nuxt/package.js
Normal file
12
distributions/nuxt/package.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export default {
|
||||||
|
build: true,
|
||||||
|
extend(pkg, { load }) {
|
||||||
|
pkg.on('build:done', () => {
|
||||||
|
const mono = load('../..')
|
||||||
|
|
||||||
|
pkg.copyFilesFrom(mono, [
|
||||||
|
'LICENSE'
|
||||||
|
])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
63
distributions/nuxt/package.json
Normal file
63
distributions/nuxt/package.json
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"name": "nuxt",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
|
||||||
|
"keywords": [
|
||||||
|
"nuxt",
|
||||||
|
"nuxt.js",
|
||||||
|
"nuxtjs",
|
||||||
|
"ssr",
|
||||||
|
"vue",
|
||||||
|
"vue isomorphic",
|
||||||
|
"vue server side",
|
||||||
|
"vue ssr",
|
||||||
|
"vue universal",
|
||||||
|
"vue versatile",
|
||||||
|
"vue.js",
|
||||||
|
"vuejs"
|
||||||
|
],
|
||||||
|
"repository": "nuxt/nuxt.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Sebastien Chopin (@Atinux)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexandre Chopin (@alexchopin)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Pooya Parsa (@pi0)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Clark Du (@clarkdo)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jonas Galvez (@galvez)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexander Lichter (@manniL}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"main": "dist/nuxt.js",
|
||||||
|
"scripts": {
|
||||||
|
"postinstall": "opencollective || exit 0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nuxt/builder": "^2.3.0",
|
||||||
|
"@nuxt/cli": "^2.3.0",
|
||||||
|
"@nuxt/common": "^2.3.0",
|
||||||
|
"@nuxt/core": "^2.3.0",
|
||||||
|
"consola": "^1.4.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0.0",
|
||||||
|
"npm": ">=5.0.0"
|
||||||
|
},
|
||||||
|
"collective": {
|
||||||
|
"url": "https://opencollective.com/nuxtjs",
|
||||||
|
"logoUrl": "https://opencollective.com/nuxtjs/logo.txt?reverse=true&variant=variant2"
|
||||||
|
}
|
||||||
|
}
|
2
distributions/nuxt/src/index.js
Normal file
2
distributions/nuxt/src/index.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from '@nuxt/core'
|
||||||
|
export * from '@nuxt/builder'
|
18
index.js
18
index.js
@ -1,18 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Nuxt.js
|
|
||||||
* (c) 2016-2018 Chopin Brothers
|
|
||||||
* Core maintainers: Pooya Parsa (@pi0) - Clark Du (@clarkdo)
|
|
||||||
* Released under the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
if (fs.existsSync(path.resolve(__dirname, '.babelrc'))) {
|
|
||||||
// Use esm version when using linked repository to prevent builds
|
|
||||||
const requireModule = require('esm')(module, {})
|
|
||||||
module.exports = requireModule('./lib/index.js').default
|
|
||||||
} else {
|
|
||||||
// Use production bundle by default
|
|
||||||
module.exports = require('./dist/nuxt.js')
|
|
||||||
}
|
|
@ -1,17 +1,42 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
coverageDirectory: './coverage/',
|
|
||||||
collectCoverageFrom: [
|
|
||||||
'lib/!(app)/**',
|
|
||||||
'!lib/builder/webpack/plugins/vue/**'
|
|
||||||
],
|
|
||||||
setupTestFrameworkScriptFile: './test/utils/setup',
|
|
||||||
testPathIgnorePatterns: ['test/fixtures/.*/.*?/'],
|
|
||||||
transformIgnorePatterns: ['<rootDir>/node_modules/'],
|
|
||||||
moduleFileExtensions: ['js', 'mjs', 'json'],
|
|
||||||
expand: true,
|
expand: true,
|
||||||
forceExit: true
|
|
||||||
|
forceExit: true,
|
||||||
|
|
||||||
// https://github.com/facebook/jest/pull/6747 fix warning here
|
// https://github.com/facebook/jest/pull/6747 fix warning here
|
||||||
// But its performance overhead is pretty bad (30+%).
|
// But its performance overhead is pretty bad (30+%).
|
||||||
// detectOpenHandles: true
|
// detectOpenHandles: true
|
||||||
|
|
||||||
|
setupTestFrameworkScriptFile: './test/utils/setup',
|
||||||
|
|
||||||
|
coverageDirectory: './coverage',
|
||||||
|
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'packages/*/src/**/*.js',
|
||||||
|
'packages/cli/bin/*'
|
||||||
|
],
|
||||||
|
|
||||||
|
coveragePathIgnorePatterns: [
|
||||||
|
'node_modules',
|
||||||
|
'packages/app',
|
||||||
|
'packages/builder/webpack/plugins/vue'
|
||||||
|
],
|
||||||
|
|
||||||
|
testPathIgnorePatterns: [
|
||||||
|
'node_modules',
|
||||||
|
'test/fixtures/.*/.*?/',
|
||||||
|
'examples/.*'
|
||||||
|
],
|
||||||
|
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
'/node_modules/',
|
||||||
|
'/dist/'
|
||||||
|
],
|
||||||
|
|
||||||
|
moduleFileExtensions: [
|
||||||
|
'js',
|
||||||
|
'json'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
19
lerna.json
Normal file
19
lerna.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"version": "independent",
|
||||||
|
"npmClient": "yarn",
|
||||||
|
"useWorkspaces": true,
|
||||||
|
"conventionalCommits": true,
|
||||||
|
"skipGit": true,
|
||||||
|
"yes": true,
|
||||||
|
"noPush": true,
|
||||||
|
"gitTagVersion": false,
|
||||||
|
"packages": [
|
||||||
|
"packages/*",
|
||||||
|
"distributions/*"
|
||||||
|
],
|
||||||
|
"command": {
|
||||||
|
"publish": {
|
||||||
|
"npmClient": "npm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
import Builder from './builder'
|
|
||||||
import Generator from './generator'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
Builder,
|
|
||||||
Generator
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
Temporary fork until [vuejs/vue#7839](https://github.com/vuejs/vue/pull/7839) arrives.
|
|
@ -1,9 +0,0 @@
|
|||||||
import Module from './module'
|
|
||||||
import Nuxt from './nuxt'
|
|
||||||
import Renderer from './renderer'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
Nuxt,
|
|
||||||
Module,
|
|
||||||
Renderer
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
import core from './core'
|
|
||||||
import builder from './builder'
|
|
||||||
import * as Utils from './common/utils'
|
|
||||||
import Options from './common/options'
|
|
||||||
|
|
||||||
export default Object.assign({ Utils, Options }, core, builder)
|
|
@ -1,4 +0,0 @@
|
|||||||
export default (pkg) => {
|
|
||||||
pkg.sortDependencies()
|
|
||||||
pkg.writePackage()
|
|
||||||
}
|
|
156
package.json
156
package.json
@ -1,143 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "nuxt",
|
"private": true,
|
||||||
"version": "2.2.0",
|
"workspaces": [
|
||||||
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
|
"packages/*",
|
||||||
"contributors": [
|
"distributions/*"
|
||||||
{
|
|
||||||
"name": "Sebastien Chopin (@Atinux)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Alexandre Chopin (@alexchopin)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Pooya Parsa (@pi0)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Clark Du (@clarkdo)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Jonas Galvez (@galvez)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Alexander Lichter (@manniL}"
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"main": "index.js",
|
|
||||||
"module": "./lib/nuxt.js",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/nuxt/nuxt.js"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"bin",
|
|
||||||
"lib",
|
|
||||||
"dist",
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"nuxt",
|
|
||||||
"nuxt.js",
|
|
||||||
"nuxtjs",
|
|
||||||
"vue",
|
|
||||||
"vue.js",
|
|
||||||
"vuejs",
|
|
||||||
"vue universal",
|
|
||||||
"vue ssr",
|
|
||||||
"vue server side",
|
|
||||||
"ssr",
|
|
||||||
"vue isomorphic",
|
|
||||||
"vue versatile"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/nuxt/nuxt.js#readme",
|
|
||||||
"bin": {
|
|
||||||
"nuxt": "./bin/nuxt"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node -r esm ./packages/nuxt-pack/build.js",
|
"build": "node -r esm ./scripts/package",
|
||||||
|
"dev": "yarn build --watch",
|
||||||
"coverage": "codecov",
|
"coverage": "codecov",
|
||||||
"lint": "eslint --ext .js,.mjs,.vue bin/** benchmarks examples lib packages test",
|
"lint": "eslint --ext .js,.mjs,.vue .",
|
||||||
"postinstall": "opencollective || exit 0",
|
"nuxt": "node -r esm ./packages/cli/bin/nuxt.js",
|
||||||
"test": "yarn test:fixtures && yarn test:unit",
|
"test": "yarn test:fixtures && yarn test:unit",
|
||||||
"test:fixtures": "jest test/fixtures",
|
"test:fixtures": "jest test/fixtures",
|
||||||
"test:e2e": "jest -i test/e2e",
|
"test:e2e": "jest -i test/e2e",
|
||||||
"test:lint": "yarn lint",
|
"test:lint": "yarn lint",
|
||||||
"test:unit": "jest test/unit"
|
"test:unit": "jest test/unit",
|
||||||
},
|
"postinstall": "lerna link"
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0.0",
|
|
||||||
"npm": ">=5.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@babel/core": "^7.1.2",
|
|
||||||
"@babel/polyfill": "^7.0.0",
|
|
||||||
"@nuxtjs/babel-preset-app": "^0.7.0",
|
|
||||||
"@nuxtjs/devalue": "^1.0.1",
|
|
||||||
"@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2",
|
|
||||||
"@nuxtjs/opencollective": "^0.1.0",
|
|
||||||
"@nuxtjs/youch": "^4.2.3",
|
|
||||||
"babel-loader": "^8.0.4",
|
|
||||||
"cache-loader": "^1.2.2",
|
|
||||||
"caniuse-lite": "^1.0.30000892",
|
|
||||||
"chalk": "^2.4.1",
|
|
||||||
"chokidar": "^2.0.4",
|
|
||||||
"compression": "^1.7.3",
|
|
||||||
"connect": "^3.6.6",
|
|
||||||
"consola": "^1.4.4",
|
|
||||||
"css-loader": "^1.0.0",
|
|
||||||
"cssnano": "^4.1.4",
|
|
||||||
"debug": "^4.1.0",
|
|
||||||
"esm": "^3.0.84",
|
|
||||||
"etag": "^1.8.1",
|
|
||||||
"file-loader": "^2.0.0",
|
|
||||||
"fresh": "^0.5.2",
|
|
||||||
"fs-extra": "^7.0.0",
|
|
||||||
"glob": "^7.1.3",
|
|
||||||
"hash-sum": "^1.0.2",
|
|
||||||
"html-minifier": "^3.5.20",
|
|
||||||
"html-webpack-plugin": "^3.2.0",
|
|
||||||
"ip": "^1.1.5",
|
|
||||||
"launch-editor-middleware": "^2.2.1",
|
|
||||||
"lodash": "^4.17.11",
|
|
||||||
"lru-cache": "^4.1.3",
|
|
||||||
"memory-fs": "^0.4.1",
|
|
||||||
"mini-css-extract-plugin": "^0.4.4",
|
|
||||||
"minimist": "^1.2.0",
|
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
|
||||||
"pify": "^4.0.0",
|
|
||||||
"postcss": "^7.0.5",
|
|
||||||
"postcss-import": "^12.0.0",
|
|
||||||
"postcss-import-resolver": "^1.1.0",
|
|
||||||
"postcss-loader": "^3.0.0",
|
|
||||||
"postcss-preset-env": "^6.1.1",
|
|
||||||
"postcss-url": "^8.0.0",
|
|
||||||
"semver": "^5.6.0",
|
|
||||||
"serialize-javascript": "^1.5.0",
|
|
||||||
"serve-static": "^1.13.2",
|
|
||||||
"server-destroy": "^1.0.1",
|
|
||||||
"std-env": "^2.0.2",
|
|
||||||
"style-resources-loader": "^1.2.1",
|
|
||||||
"terser-webpack-plugin": "^1.1.0",
|
|
||||||
"thread-loader": "^1.2.0",
|
|
||||||
"time-fix-plugin": "^2.0.4",
|
|
||||||
"upath": "^1.1.0",
|
|
||||||
"url-loader": "^1.1.2",
|
|
||||||
"vue": "^2.5.17",
|
|
||||||
"vue-loader": "^15.4.2",
|
|
||||||
"vue-meta": "^1.5.5",
|
|
||||||
"vue-no-ssr": "^1.0.0",
|
|
||||||
"vue-router": "^3.0.1",
|
|
||||||
"vue-server-renderer": "^2.5.17",
|
|
||||||
"vue-template-compiler": "^2.5.17",
|
|
||||||
"vuex": "^3.0.1",
|
|
||||||
"webpack": "^4.20.2",
|
|
||||||
"webpack-bundle-analyzer": "^3.0.2",
|
|
||||||
"webpack-dev-middleware": "^3.4.0",
|
|
||||||
"webpack-hot-middleware": "^2.24.3",
|
|
||||||
"webpack-node-externals": "^1.7.2",
|
|
||||||
"webpackbar": "^2.6.3"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.1.2",
|
||||||
"@babel/preset-env": "^7.1.0",
|
"@babel/preset-env": "^7.1.0",
|
||||||
"@nuxtjs/eslint-config": "^0.0.1",
|
"@nuxtjs/eslint-config": "^0.0.1",
|
||||||
"babel-core": "^7.0.0-bridge",
|
"babel-core": "^7.0.0-bridge",
|
||||||
@ -145,6 +26,7 @@
|
|||||||
"babel-jest": "^23.6.0",
|
"babel-jest": "^23.6.0",
|
||||||
"babel-plugin-dynamic-import-node": "^2.2.0",
|
"babel-plugin-dynamic-import-node": "^2.2.0",
|
||||||
"codecov": "^3.1.0",
|
"codecov": "^3.1.0",
|
||||||
|
"consola": "^1.4.4",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"cross-spawn": "^6.0.5",
|
"cross-spawn": "^6.0.5",
|
||||||
"eslint": "^5.7.0",
|
"eslint": "^5.7.0",
|
||||||
@ -155,12 +37,17 @@
|
|||||||
"eslint-plugin-promise": "^4.0.1",
|
"eslint-plugin-promise": "^4.0.1",
|
||||||
"eslint-plugin-standard": "^4.0.0",
|
"eslint-plugin-standard": "^4.0.0",
|
||||||
"eslint-plugin-vue": "^5.0.0-beta.3",
|
"eslint-plugin-vue": "^5.0.0-beta.3",
|
||||||
|
"esm": "^3.0.84",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"finalhandler": "^1.1.1",
|
"finalhandler": "^1.1.1",
|
||||||
|
"fs-extra": "^7.0.0",
|
||||||
"get-port": "^4.0.0",
|
"get-port": "^4.0.0",
|
||||||
|
"glob": "^7.1.3",
|
||||||
"jest": "^23.6.0",
|
"jest": "^23.6.0",
|
||||||
"jsdom": "^12.2.0",
|
"jsdom": "^12.2.0",
|
||||||
"klaw-sync": "^6.0.0",
|
"klaw-sync": "^6.0.0",
|
||||||
|
"lerna": "^3.4.3",
|
||||||
|
"lodash": "^4.17.11",
|
||||||
"pug": "^2.0.3",
|
"pug": "^2.0.3",
|
||||||
"pug-plain-loader": "^1.0.0",
|
"pug-plain-loader": "^1.0.0",
|
||||||
"puppeteer": "^1.9.0",
|
"puppeteer": "^1.9.0",
|
||||||
@ -168,13 +55,12 @@
|
|||||||
"request-promise-native": "^1.0.5",
|
"request-promise-native": "^1.0.5",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"rollup": "^0.66.6",
|
"rollup": "^0.66.6",
|
||||||
|
"rollup-plugin-alias": "^1.4.0",
|
||||||
"rollup-plugin-babel": "^4.0.3",
|
"rollup-plugin-babel": "^4.0.3",
|
||||||
"rollup-plugin-commonjs": "^9.2.0",
|
"rollup-plugin-commonjs": "^9.2.0",
|
||||||
"rollup-plugin-json": "^3.1.0",
|
"rollup-plugin-json": "^3.1.0",
|
||||||
"rollup-plugin-license": "^0.7.0"
|
"rollup-plugin-license": "^0.7.0",
|
||||||
},
|
"rollup-plugin-replace": "^2.1.0",
|
||||||
"collective": {
|
"sort-package-json": "^1.16.0"
|
||||||
"url": "https://opencollective.com/nuxtjs",
|
|
||||||
"logoUrl": "https://opencollective.com/nuxtjs/logo.txt?reverse=true&variant=variant2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
packages/app/CHANGELOG.md
Normal file
11
packages/app/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# 2.3.0 (2018-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Migrate Nuxt into monorepo
|
3
packages/app/package.js
Normal file
3
packages/app/package.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
build: true
|
||||||
|
}
|
11
packages/app/package.json
Normal file
11
packages/app/package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "@nuxt/app",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"repository": "nuxt/nuxt.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"template"
|
||||||
|
],
|
||||||
|
"main": "dist/app.js"
|
||||||
|
}
|
25
packages/app/src/index.js
Normal file
25
packages/app/src/index.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import path from 'path'
|
||||||
|
import pkg from '../package.json'
|
||||||
|
|
||||||
|
export const meta = pkg
|
||||||
|
|
||||||
|
export const templatesDir = path.join(__dirname, '..', 'template')
|
||||||
|
|
||||||
|
export const templatesFiles = [
|
||||||
|
'App.js',
|
||||||
|
'client.js',
|
||||||
|
'index.js',
|
||||||
|
'middleware.js',
|
||||||
|
'router.js',
|
||||||
|
'server.js',
|
||||||
|
'utils.js',
|
||||||
|
'empty.js',
|
||||||
|
'components/nuxt-error.vue',
|
||||||
|
'components/nuxt-loading.vue',
|
||||||
|
'components/nuxt-child.js',
|
||||||
|
'components/nuxt-link.js',
|
||||||
|
'components/nuxt.js',
|
||||||
|
'components/no-ssr.js',
|
||||||
|
'views/app.template.html',
|
||||||
|
'views/error.html'
|
||||||
|
]
|
@ -91,7 +91,7 @@ async function createApp (ssrContext) {
|
|||||||
const nuxt = this.nuxt || this.$options.nuxt
|
const nuxt = this.nuxt || this.$options.nuxt
|
||||||
nuxt.dateErr = Date.now()
|
nuxt.dateErr = Date.now()
|
||||||
nuxt.err = err
|
nuxt.err = err
|
||||||
// Used in lib/server.js
|
// Used in src/server.js
|
||||||
if (ssrContext) ssrContext.nuxt.error = err
|
if (ssrContext) ssrContext.nuxt.error = err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
11
packages/builder/CHANGELOG.md
Normal file
11
packages/builder/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# 2.3.0 (2018-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Migrate Nuxt into monorepo
|
3
packages/builder/package.js
Normal file
3
packages/builder/package.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
build: true
|
||||||
|
}
|
58
packages/builder/package.json
Normal file
58
packages/builder/package.json
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"name": "@nuxt/builder",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"repository": "nuxt/nuxt.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"main": "dist/builder.js",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/core": "^7.1.2",
|
||||||
|
"@babel/polyfill": "^7.0.0",
|
||||||
|
"@nuxt/app": "^2.3.0",
|
||||||
|
"@nuxt/common": "^2.3.0",
|
||||||
|
"@nuxtjs/babel-preset-app": "^0.7.0",
|
||||||
|
"@nuxtjs/devalue": "^1.0.1",
|
||||||
|
"@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2",
|
||||||
|
"babel-loader": "^8.0.4",
|
||||||
|
"cache-loader": "^1.2.2",
|
||||||
|
"caniuse-lite": "^1.0.30000892",
|
||||||
|
"chalk": "^2.4.1",
|
||||||
|
"chokidar": "^2.0.4",
|
||||||
|
"consola": "^1.4.4",
|
||||||
|
"css-loader": "^1.0.0",
|
||||||
|
"cssnano": "^4.1.4",
|
||||||
|
"file-loader": "^2.0.0",
|
||||||
|
"fs-extra": "^7.0.0",
|
||||||
|
"glob": "^7.1.3",
|
||||||
|
"hash-sum": "^1.0.2",
|
||||||
|
"html-minifier": "^3.5.20",
|
||||||
|
"html-webpack-plugin": "^3.2.0",
|
||||||
|
"lodash": "^4.17.11",
|
||||||
|
"memory-fs": "^0.4.1",
|
||||||
|
"mini-css-extract-plugin": "^0.4.3",
|
||||||
|
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
||||||
|
"pify": "^4.0.0",
|
||||||
|
"postcss": "^7.0.5",
|
||||||
|
"postcss-import": "^12.0.0",
|
||||||
|
"postcss-import-resolver": "^1.1.0",
|
||||||
|
"postcss-loader": "^3.0.0",
|
||||||
|
"postcss-preset-env": "^6.0.10",
|
||||||
|
"postcss-url": "^8.0.0",
|
||||||
|
"serialize-javascript": "^1.5.0",
|
||||||
|
"style-resources-loader": "^1.2.1",
|
||||||
|
"terser-webpack-plugin": "^1.1.0",
|
||||||
|
"thread-loader": "^1.2.0",
|
||||||
|
"time-fix-plugin": "^2.0.4",
|
||||||
|
"upath": "^1.1.0",
|
||||||
|
"url-loader": "^1.1.1",
|
||||||
|
"vue-loader": "^15.4.2",
|
||||||
|
"webpack": "^4.20.2",
|
||||||
|
"webpack-bundle-analyzer": "^3.0.2",
|
||||||
|
"webpack-dev-middleware": "^3.4.0",
|
||||||
|
"webpack-hot-middleware": "^2.24.3",
|
||||||
|
"webpack-node-externals": "^1.7.2",
|
||||||
|
"webpackbar": "^2.6.3"
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
|
||||||
import pify from 'pify'
|
import pify from 'pify'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import chokidar from 'chokidar'
|
import chokidar from 'chokidar'
|
||||||
@ -8,7 +7,6 @@ import fsExtra from 'fs-extra'
|
|||||||
import hash from 'hash-sum'
|
import hash from 'hash-sum'
|
||||||
import webpack from 'webpack'
|
import webpack from 'webpack'
|
||||||
import serialize from 'serialize-javascript'
|
import serialize from 'serialize-javascript'
|
||||||
import devalue from '@nuxtjs/devalue'
|
|
||||||
import MFS from 'memory-fs'
|
import MFS from 'memory-fs'
|
||||||
import webpackDevMiddleware from 'webpack-dev-middleware'
|
import webpackDevMiddleware from 'webpack-dev-middleware'
|
||||||
import webpackHotMiddleware from 'webpack-hot-middleware'
|
import webpackHotMiddleware from 'webpack-hot-middleware'
|
||||||
@ -16,7 +14,10 @@ import Glob from 'glob'
|
|||||||
import upath from 'upath'
|
import upath from 'upath'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
|
||||||
|
import devalue from '@nuxtjs/devalue'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Options,
|
||||||
r,
|
r,
|
||||||
wp,
|
wp,
|
||||||
wChunk,
|
wChunk,
|
||||||
@ -26,9 +27,8 @@ import {
|
|||||||
relativeTo,
|
relativeTo,
|
||||||
waitFor,
|
waitFor,
|
||||||
determineGlobals
|
determineGlobals
|
||||||
} from '../common/utils'
|
} from '@nuxt/common'
|
||||||
|
|
||||||
import Options from '../common/options'
|
|
||||||
import PerfLoader from './webpack/utils/perf-loader'
|
import PerfLoader from './webpack/utils/perf-loader'
|
||||||
import ClientWebpackConfig from './webpack/client'
|
import ClientWebpackConfig from './webpack/client'
|
||||||
import ServerWebpackConfig from './webpack/server'
|
import ServerWebpackConfig from './webpack/server'
|
||||||
@ -79,6 +79,12 @@ export default class Builder {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resolve template
|
||||||
|
this.template = this.options.build.template || '@nuxt/app'
|
||||||
|
if (typeof this.template === 'string') {
|
||||||
|
this.template = this.nuxt.resolver.requireModule(this.template)
|
||||||
|
}
|
||||||
|
|
||||||
// if(!this.options.dev) {
|
// if(!this.options.dev) {
|
||||||
// TODO: enable again when unsafe concern resolved.(common/options.js:42)
|
// TODO: enable again when unsafe concern resolved.(common/options.js:42)
|
||||||
// this.nuxt.hook('build:done', () => this.generateConfig())
|
// this.nuxt.hook('build:done', () => this.generateConfig())
|
||||||
@ -94,7 +100,7 @@ export default class Builder {
|
|||||||
''
|
''
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
src: this.nuxt.resolveAlias(p.src),
|
src: this.nuxt.resolver.resolveAlias(p.src),
|
||||||
ssr: p.ssr !== false,
|
ssr: p.ssr !== false,
|
||||||
name: 'nuxt_plugin_' + pluginBaseName + '_' + hash(p.src)
|
name: 'nuxt_plugin_' + pluginBaseName + '_' + hash(p.src)
|
||||||
}
|
}
|
||||||
@ -190,24 +196,8 @@ export default class Builder {
|
|||||||
this.plugins = this.normalizePlugins()
|
this.plugins = this.normalizePlugins()
|
||||||
|
|
||||||
// -- Templates --
|
// -- Templates --
|
||||||
let templatesFiles = [
|
let templatesFiles = Array.from(this.template.templatesFiles)
|
||||||
'App.js',
|
|
||||||
'client.js',
|
|
||||||
'index.js',
|
|
||||||
'middleware.js',
|
|
||||||
'router.js',
|
|
||||||
'server.js',
|
|
||||||
'utils.js',
|
|
||||||
'empty.js',
|
|
||||||
'components/nuxt-error.vue',
|
|
||||||
'components/nuxt-loading.vue',
|
|
||||||
'components/nuxt-child.js',
|
|
||||||
'components/nuxt-link.js',
|
|
||||||
'components/nuxt.js',
|
|
||||||
'components/no-ssr.js',
|
|
||||||
'views/app.template.html',
|
|
||||||
'views/error.html'
|
|
||||||
]
|
|
||||||
const templateVars = {
|
const templateVars = {
|
||||||
options: this.options,
|
options: this.options,
|
||||||
extensions: this.options.extensions
|
extensions: this.options.extensions
|
||||||
@ -286,7 +276,7 @@ export default class Builder {
|
|||||||
if (this._defaultPage) {
|
if (this._defaultPage) {
|
||||||
templateVars.router.routes = createRoutes(
|
templateVars.router.routes = createRoutes(
|
||||||
['index.vue'],
|
['index.vue'],
|
||||||
this.options.nuxtAppDir + '/pages'
|
this.template.templatesDir + '/pages'
|
||||||
)
|
)
|
||||||
} else if (this._nuxtPages) { // If user defined a custom method to create routes
|
} else if (this._nuxtPages) { // If user defined a custom method to create routes
|
||||||
// Use nuxt.js createRoutes bases on pages/
|
// Use nuxt.js createRoutes bases on pages/
|
||||||
@ -354,7 +344,7 @@ export default class Builder {
|
|||||||
const customFileExists = fsExtra.existsSync(customPath)
|
const customFileExists = fsExtra.existsSync(customPath)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
src: customFileExists ? customPath : r(this.options.nuxtAppDir, file),
|
src: customFileExists ? customPath : r(this.template.templatesDir, file),
|
||||||
dst: file,
|
dst: file,
|
||||||
custom: customFileExists
|
custom: customFileExists
|
||||||
}
|
}
|
||||||
@ -379,11 +369,11 @@ export default class Builder {
|
|||||||
// -- Loading indicator --
|
// -- Loading indicator --
|
||||||
if (this.options.loadingIndicator.name) {
|
if (this.options.loadingIndicator.name) {
|
||||||
const indicatorPath1 = path.resolve(
|
const indicatorPath1 = path.resolve(
|
||||||
this.options.nuxtAppDir,
|
this.template.templatesDir,
|
||||||
'views/loading',
|
'views/loading',
|
||||||
this.options.loadingIndicator.name + '.html'
|
this.options.loadingIndicator.name + '.html'
|
||||||
)
|
)
|
||||||
const indicatorPath2 = this.nuxt.resolveAlias(
|
const indicatorPath2 = this.nuxt.resolver.resolveAlias(
|
||||||
this.options.loadingIndicator.name
|
this.options.loadingIndicator.name
|
||||||
)
|
)
|
||||||
const indicatorPath = fsExtra.existsSync(indicatorPath1)
|
const indicatorPath = fsExtra.existsSync(indicatorPath1)
|
||||||
@ -429,8 +419,8 @@ export default class Builder {
|
|||||||
r,
|
r,
|
||||||
wp,
|
wp,
|
||||||
wChunk,
|
wChunk,
|
||||||
resolvePath: this.nuxt.resolvePath,
|
resolvePath: this.nuxt.resolver.resolvePath,
|
||||||
resolveAlias: this.nuxt.resolveAlias,
|
resolveAlias: this.nuxt.resolver.resolveAlias,
|
||||||
relativeToBuild: this.relativeToBuild
|
relativeToBuild: this.relativeToBuild
|
||||||
},
|
},
|
||||||
interpolate: /<%=([\s\S]+?)%>/g
|
interpolate: /<%=([\s\S]+?)%>/g
|
||||||
@ -672,8 +662,8 @@ export default class Builder {
|
|||||||
const nuxtRestartWatch = _.concat(
|
const nuxtRestartWatch = _.concat(
|
||||||
this.options.serverMiddleware
|
this.options.serverMiddleware
|
||||||
.filter(i => typeof i === 'string')
|
.filter(i => typeof i === 'string')
|
||||||
.map(this.nuxt.resolveAlias),
|
.map(this.nuxt.resolver.resolveAlias),
|
||||||
this.options.watch.map(this.nuxt.resolveAlias),
|
this.options.watch.map(this.nuxt.resolver.resolveAlias),
|
||||||
path.join(this.options.rootDir, 'nuxt.config.js')
|
path.join(this.options.rootDir, 'nuxt.config.js')
|
||||||
)
|
)
|
||||||
|
|
@ -3,7 +3,8 @@ import htmlMinifier from 'html-minifier'
|
|||||||
import Chalk from 'chalk'
|
import Chalk from 'chalk'
|
||||||
import fsExtra from 'fs-extra'
|
import fsExtra from 'fs-extra'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { flatRoutes, isUrl, promisifyRoute, waitFor, isString } from '../common/utils'
|
|
||||||
|
import { flatRoutes, isUrl, promisifyRoute, waitFor, isString } from '@nuxt/common'
|
||||||
|
|
||||||
export default class Generator {
|
export default class Generator {
|
||||||
constructor(nuxt, builder) {
|
constructor(nuxt, builder) {
|
2
packages/builder/src/index.js
Normal file
2
packages/builder/src/index.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export { default as Builder } from './builder'
|
||||||
|
export { default as Generator } from './generator'
|
@ -1,13 +1,13 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
|
||||||
import TimeFixPlugin from 'time-fix-plugin'
|
import TimeFixPlugin from 'time-fix-plugin'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import VueLoader from 'vue-loader'
|
import VueLoader from 'vue-loader'
|
||||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
||||||
import WebpackBar from 'webpackbar'
|
import WebpackBar from 'webpackbar'
|
||||||
|
|
||||||
import { isUrl, urlJoin } from '../../common/utils'
|
import { isUrl, urlJoin } from '@nuxt/common'
|
||||||
|
|
||||||
import StyleLoader from './utils/style-loader'
|
import StyleLoader from './utils/style-loader'
|
||||||
import WarnFixPlugin from './plugins/warnfix'
|
import WarnFixPlugin from './plugins/warnfix'
|
||||||
import StatsPlugin from './plugins/stats'
|
import StatsPlugin from './plugins/stats'
|
@ -1,5 +1,4 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
import webpack from 'webpack'
|
import webpack from 'webpack'
|
||||||
import HTMLPlugin from 'html-webpack-plugin'
|
import HTMLPlugin from 'html-webpack-plugin'
|
||||||
import BundleAnalyzer from 'webpack-bundle-analyzer'
|
import BundleAnalyzer from 'webpack-bundle-analyzer'
|
@ -1,5 +1,6 @@
|
|||||||
import hash from 'hash-sum'
|
import hash from 'hash-sum'
|
||||||
import { uniq } from 'lodash'
|
import { uniq } from 'lodash'
|
||||||
|
|
||||||
import { isJS, isCSS, onEmit } from './util'
|
import { isJS, isCSS, onEmit } from './util'
|
||||||
|
|
||||||
export default class VueSSRClientPlugin {
|
export default class VueSSRClientPlugin {
|
@ -1,6 +1,5 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
|
||||||
import webpack from 'webpack'
|
import webpack from 'webpack'
|
||||||
import nodeExternals from 'webpack-node-externals'
|
import nodeExternals from 'webpack-node-externals'
|
||||||
|
|
@ -1,10 +1,9 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import createResolver from 'postcss-import-resolver'
|
import createResolver from 'postcss-import-resolver'
|
||||||
|
|
||||||
import { isPureObject } from '../../../common/utils'
|
import { isPureObject } from '@nuxt/common'
|
||||||
|
|
||||||
export default class PostcssConfig {
|
export default class PostcssConfig {
|
||||||
constructor(options, nuxt) {
|
constructor(options, nuxt) {
|
@ -1,5 +1,7 @@
|
|||||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
||||||
import { wrapArray } from '../../../common/utils'
|
|
||||||
|
import { wrapArray } from '@nuxt/common'
|
||||||
|
|
||||||
import PostcssConfig from './postcss'
|
import PostcssConfig from './postcss'
|
||||||
|
|
||||||
export default class StyleLoader {
|
export default class StyleLoader {
|
11
packages/cli/CHANGELOG.md
Normal file
11
packages/cli/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# 2.3.0 (2018-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Migrate Nuxt into monorepo
|
@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const { join } = require('path')
|
|
||||||
|
|
||||||
const consola = require('consola')
|
const consola = require('consola')
|
||||||
|
const cli = require('../dist/cli.js')
|
||||||
|
|
||||||
// Global error handler
|
// Global error handler
|
||||||
process.on('unhandledRejection', err => consola.error(err))
|
process.on('unhandledRejection', (err) => {
|
||||||
|
consola.error(err)
|
||||||
|
})
|
||||||
|
|
||||||
// Exit process on fatal errors
|
// Exit process on fatal errors
|
||||||
consola.add({
|
consola.add({
|
||||||
@ -17,7 +19,12 @@ consola.add({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const defaultCommand = 'dev'
|
const defaultCommand = 'dev'
|
||||||
const commands = new Set([defaultCommand, 'init', 'build', 'start', 'generate'])
|
const commands = new Set([
|
||||||
|
defaultCommand,
|
||||||
|
'build',
|
||||||
|
'start',
|
||||||
|
'generate'
|
||||||
|
])
|
||||||
|
|
||||||
let cmd = process.argv[2]
|
let cmd = process.argv[2]
|
||||||
|
|
||||||
@ -27,6 +34,11 @@ if (commands.has(cmd)) {
|
|||||||
cmd = defaultCommand
|
cmd = defaultCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
const bin = join(__dirname, 'nuxt-' + cmd)
|
// Apply default NODE_ENV if not provided
|
||||||
|
if (!process.env.NODE_ENV) {
|
||||||
|
process.env.NODE_ENV = cmd === 'dev' ? 'development' : 'production'
|
||||||
|
}
|
||||||
|
|
||||||
require(bin)
|
cli[cmd]().then(m => m.default()).catch((error) => {
|
||||||
|
consola.fatal(error)
|
||||||
|
})
|
3
packages/cli/package.js
Normal file
3
packages/cli/package.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
build: true
|
||||||
|
}
|
19
packages/cli/package.json
Normal file
19
packages/cli/package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "@nuxt/cli",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"repository": "nuxt/nuxt.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"bin",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"main": "dist/cli.js",
|
||||||
|
"bin": {
|
||||||
|
"nuxt": "bin/nuxt.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"consola": "^1.4.4",
|
||||||
|
"esm": "^3.0.84",
|
||||||
|
"minimist": "^1.2.0"
|
||||||
|
}
|
||||||
|
}
|
90
packages/cli/src/commands/build.js
Normal file
90
packages/cli/src/commands/build.js
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import parseArgs from 'minimist'
|
||||||
|
import consola from 'consola'
|
||||||
|
|
||||||
|
import { loadNuxtConfig } from '../common/utils'
|
||||||
|
|
||||||
|
export default async function build() {
|
||||||
|
const { Nuxt } = await import('@nuxt/core')
|
||||||
|
const { Builder, Generator } = await import('@nuxt/builder')
|
||||||
|
|
||||||
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
|
alias: {
|
||||||
|
h: 'help',
|
||||||
|
c: 'config-file',
|
||||||
|
a: 'analyze',
|
||||||
|
s: 'spa',
|
||||||
|
u: 'universal',
|
||||||
|
q: 'quiet'
|
||||||
|
},
|
||||||
|
boolean: ['h', 'a', 's', 'u', 'q'],
|
||||||
|
string: ['c'],
|
||||||
|
default: {
|
||||||
|
c: 'nuxt.config.js'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (argv.help) {
|
||||||
|
process.stderr.write(`
|
||||||
|
Description
|
||||||
|
Compiles the application for production deployment
|
||||||
|
Usage
|
||||||
|
$ nuxt build <dir>
|
||||||
|
Options
|
||||||
|
--analyze, -a Launch webpack-bundle-analyzer to optimize your bundles.
|
||||||
|
--spa, -s Launch in SPA mode
|
||||||
|
--universal, -u Launch in Universal mode (default)
|
||||||
|
--no-generate Don't generate static version for SPA mode (useful for nuxt start)
|
||||||
|
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
||||||
|
--quiet, -q Disable output except for errors
|
||||||
|
--help, -h Displays this message
|
||||||
|
`)
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = loadNuxtConfig(argv)
|
||||||
|
|
||||||
|
// Create production build when calling `nuxt build`
|
||||||
|
options.dev = false
|
||||||
|
|
||||||
|
// Analyze option
|
||||||
|
options.build = options.build || {}
|
||||||
|
if (argv.analyze && typeof options.build.analyze !== 'object') {
|
||||||
|
options.build.analyze = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Silence output when using --quiet
|
||||||
|
if (argv.quiet) {
|
||||||
|
options.build.quiet = !!argv.quiet
|
||||||
|
}
|
||||||
|
|
||||||
|
const nuxt = new Nuxt(options)
|
||||||
|
const builder = new Builder(nuxt)
|
||||||
|
|
||||||
|
// Setup hooks
|
||||||
|
nuxt.hook('error', err => consola.fatal(err))
|
||||||
|
|
||||||
|
// Close function
|
||||||
|
const close = () => {
|
||||||
|
// In analyze mode wait for plugin
|
||||||
|
// emitting assets and opening browser
|
||||||
|
if (options.build.analyze === true || typeof options.build.analyze === 'object') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.mode !== 'spa' || argv.generate === false) {
|
||||||
|
// Build only
|
||||||
|
return builder
|
||||||
|
.build()
|
||||||
|
.then(close)
|
||||||
|
.catch(err => consola.fatal(err))
|
||||||
|
} else {
|
||||||
|
// Build + Generate for static deployment
|
||||||
|
return new Generator(nuxt, builder)
|
||||||
|
.generate({ build: true })
|
||||||
|
.then(close)
|
||||||
|
.catch(err => consola.fatal(err))
|
||||||
|
}
|
||||||
|
}
|
100
packages/cli/src/commands/dev.js
Normal file
100
packages/cli/src/commands/dev.js
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
import parseArgs from 'minimist'
|
||||||
|
import consola from 'consola'
|
||||||
|
import { loadNuxtConfig } from '../common/utils'
|
||||||
|
|
||||||
|
export default async function dev() {
|
||||||
|
const { Nuxt } = await import('@nuxt/core')
|
||||||
|
const { Builder } = await import('@nuxt/builder')
|
||||||
|
|
||||||
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
|
alias: {
|
||||||
|
h: 'help',
|
||||||
|
H: 'hostname',
|
||||||
|
p: 'port',
|
||||||
|
c: 'config-file',
|
||||||
|
s: 'spa',
|
||||||
|
u: 'universal',
|
||||||
|
v: 'version'
|
||||||
|
},
|
||||||
|
boolean: ['h', 's', 'u', 'v'],
|
||||||
|
string: ['H', 'c'],
|
||||||
|
default: {
|
||||||
|
c: 'nuxt.config.js'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (argv.version) {
|
||||||
|
process.stderr.write('TODO' + '\n')
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.hostname === '') {
|
||||||
|
consola.fatal('Provided hostname argument has no value')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.help) {
|
||||||
|
process.stderr.write(`
|
||||||
|
Description
|
||||||
|
Starts the application in development mode (hot-code reloading, error
|
||||||
|
reporting, etc)
|
||||||
|
Usage
|
||||||
|
$ nuxt dev <dir> -p <port number> -H <hostname>
|
||||||
|
Options
|
||||||
|
--port, -p A port number on which to start the application
|
||||||
|
--hostname, -H Hostname on which to start the application
|
||||||
|
--spa Launch in SPA mode
|
||||||
|
--universal Launch in Universal mode (default)
|
||||||
|
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
||||||
|
--help, -h Displays this message
|
||||||
|
`)
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = () => {
|
||||||
|
// Force development mode for add hot reloading and watching changes
|
||||||
|
return Object.assign(loadNuxtConfig(argv), { dev: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const errorHandler = (err, instance) => {
|
||||||
|
instance && instance.builder.watchServer()
|
||||||
|
consola.error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start dev
|
||||||
|
(function startDev(oldInstance) {
|
||||||
|
let nuxt, builder
|
||||||
|
|
||||||
|
try {
|
||||||
|
nuxt = new Nuxt(config())
|
||||||
|
builder = new Builder(nuxt)
|
||||||
|
nuxt.hook('watch:fileChanged', (builder, fname) => {
|
||||||
|
consola.debug(`[${fname}] changed, Rebuilding the app...`)
|
||||||
|
startDev({ nuxt: builder.nuxt, builder })
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
return errorHandler(err, oldInstance)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
Promise.resolve()
|
||||||
|
.then(() => oldInstance && oldInstance.nuxt.clearHook('watch:fileChanged'))
|
||||||
|
.then(() => oldInstance && oldInstance.builder.unwatch())
|
||||||
|
// Start build
|
||||||
|
.then(() => builder.build())
|
||||||
|
// Close old nuxt no mater if build successfully
|
||||||
|
.catch((err) => {
|
||||||
|
oldInstance && oldInstance.nuxt.close()
|
||||||
|
// Jump to eventHandler
|
||||||
|
throw err
|
||||||
|
})
|
||||||
|
.then(() => oldInstance && oldInstance.nuxt.close())
|
||||||
|
// Start listening
|
||||||
|
.then(() => nuxt.listen())
|
||||||
|
// Show ready message first time, others will be shown through WebpackBar
|
||||||
|
.then(() => !oldInstance && nuxt.showReady(false))
|
||||||
|
.then(() => builder.watchServer())
|
||||||
|
// Handle errors
|
||||||
|
.catch(err => errorHandler(err, { builder, nuxt }))
|
||||||
|
)
|
||||||
|
})()
|
||||||
|
}
|
60
packages/cli/src/commands/generate.js
Normal file
60
packages/cli/src/commands/generate.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import parseArgs from 'minimist'
|
||||||
|
import consola from 'consola'
|
||||||
|
|
||||||
|
import { loadNuxtConfig } from '../common/utils'
|
||||||
|
|
||||||
|
export default async function generate() {
|
||||||
|
const { Nuxt } = await import('@nuxt/core')
|
||||||
|
const { Builder, Generator } = await import('@nuxt/builder')
|
||||||
|
|
||||||
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
|
alias: {
|
||||||
|
h: 'help',
|
||||||
|
c: 'config-file',
|
||||||
|
s: 'spa',
|
||||||
|
u: 'universal'
|
||||||
|
},
|
||||||
|
boolean: ['h', 's', 'u', 'build'],
|
||||||
|
string: ['c'],
|
||||||
|
default: {
|
||||||
|
c: 'nuxt.config.js',
|
||||||
|
build: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (argv.help) {
|
||||||
|
process.stderr.write(`
|
||||||
|
Description
|
||||||
|
Generate a static web application (server-rendered)
|
||||||
|
Usage
|
||||||
|
$ nuxt generate <dir>
|
||||||
|
Options
|
||||||
|
--spa Launch in SPA mode
|
||||||
|
--universal Launch in Universal mode (default)
|
||||||
|
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
||||||
|
--help, -h Displays this message
|
||||||
|
--no-build Just run generate for faster builds when just dynamic routes changed. Nuxt build is needed before this command.
|
||||||
|
`)
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = loadNuxtConfig(argv)
|
||||||
|
|
||||||
|
options.dev = false // Force production mode (no webpack middleware called)
|
||||||
|
|
||||||
|
const nuxt = new Nuxt(options)
|
||||||
|
const builder = new Builder(nuxt)
|
||||||
|
const generator = new Generator(nuxt, builder)
|
||||||
|
|
||||||
|
const generateOptions = {
|
||||||
|
init: true,
|
||||||
|
build: argv.build
|
||||||
|
}
|
||||||
|
|
||||||
|
return generator
|
||||||
|
.generate(generateOptions)
|
||||||
|
.then(() => {
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch(err => consola.fatal(err))
|
||||||
|
}
|
87
packages/cli/src/commands/start.js
Normal file
87
packages/cli/src/commands/start.js
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
import parseArgs from 'minimist'
|
||||||
|
import consola from 'consola'
|
||||||
|
|
||||||
|
import { loadNuxtConfig } from '../common/utils'
|
||||||
|
|
||||||
|
export default async function start() {
|
||||||
|
const { Nuxt } = await import('@nuxt/core')
|
||||||
|
|
||||||
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
|
alias: {
|
||||||
|
h: 'help',
|
||||||
|
H: 'hostname',
|
||||||
|
p: 'port',
|
||||||
|
n: 'unix-socket',
|
||||||
|
c: 'config-file',
|
||||||
|
s: 'spa',
|
||||||
|
u: 'universal'
|
||||||
|
},
|
||||||
|
boolean: ['h', 's', 'u'],
|
||||||
|
string: ['H', 'c', 'n'],
|
||||||
|
default: {
|
||||||
|
c: 'nuxt.config.js'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (argv.hostname === '') {
|
||||||
|
consola.fatal('Provided hostname argument has no value')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.help) {
|
||||||
|
process.stderr.write(`
|
||||||
|
Description
|
||||||
|
Starts the application in production mode.
|
||||||
|
The application should be compiled with \`nuxt build\` first.
|
||||||
|
Usage
|
||||||
|
$ nuxt start <dir> -p <port number> -H <hostname>
|
||||||
|
Options
|
||||||
|
--port, -p A port number on which to start the application
|
||||||
|
--hostname, -H Hostname on which to start the application
|
||||||
|
--unix-socket, -n Path to a UNIX socket
|
||||||
|
--spa Launch in SPA mode
|
||||||
|
--universal Launch in Universal mode (default)
|
||||||
|
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
|
||||||
|
--help, -h Displays this message
|
||||||
|
`)
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = loadNuxtConfig(argv)
|
||||||
|
|
||||||
|
// Force production mode (no webpack middleware called)
|
||||||
|
options.dev = false
|
||||||
|
|
||||||
|
const nuxt = new Nuxt(options)
|
||||||
|
|
||||||
|
// Setup hooks
|
||||||
|
nuxt.hook('error', err => consola.fatal(err))
|
||||||
|
|
||||||
|
// Check if project is built for production
|
||||||
|
const distDir = path.resolve(
|
||||||
|
nuxt.options.rootDir,
|
||||||
|
nuxt.options.buildDir || '.nuxt',
|
||||||
|
'dist',
|
||||||
|
'server'
|
||||||
|
)
|
||||||
|
if (!fs.existsSync(distDir)) {
|
||||||
|
consola.fatal(
|
||||||
|
'No build files found, please run `nuxt build` before launching `nuxt start`'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if SSR Bundle is required
|
||||||
|
if (nuxt.options.render.ssr === true) {
|
||||||
|
const ssrBundlePath = path.resolve(distDir, 'server-bundle.json')
|
||||||
|
if (!fs.existsSync(ssrBundlePath)) {
|
||||||
|
consola.fatal(
|
||||||
|
'No SSR build! Please start with `nuxt start --spa` or build using `nuxt build --universal`'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nuxt.listen().then(() => {
|
||||||
|
nuxt.showReady(false)
|
||||||
|
})
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
|
|
||||||
const { resolve } = require('path')
|
import path from 'path'
|
||||||
const { existsSync } = require('fs')
|
import { existsSync } from 'fs'
|
||||||
const consola = require('consola')
|
import consola from 'consola'
|
||||||
const esm = require('esm')(module, {
|
import esm from 'esm'
|
||||||
|
|
||||||
|
const _require = esm(module, {
|
||||||
cache: false,
|
cache: false,
|
||||||
cjs: {
|
cjs: {
|
||||||
cache: true,
|
cache: true,
|
||||||
@ -11,8 +13,8 @@ const esm = require('esm')(module, {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const getRootDir = argv => resolve(argv._[0] || '.')
|
const getRootDir = argv => path.resolve(argv._[0] || '.')
|
||||||
const getNuxtConfigFile = argv => resolve(getRootDir(argv), argv['config-file'])
|
const getNuxtConfigFile = argv => path.resolve(getRootDir(argv), argv['config-file'])
|
||||||
const getLatestHost = (argv) => {
|
const getLatestHost = (argv) => {
|
||||||
const port =
|
const port =
|
||||||
argv.port ||
|
argv.port ||
|
||||||
@ -32,9 +34,7 @@ const getLatestHost = (argv) => {
|
|||||||
return { port, host, socket }
|
return { port, host, socket }
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.nuxtConfigFile = getNuxtConfigFile
|
export function loadNuxtConfig(argv) {
|
||||||
|
|
||||||
exports.loadNuxtConfig = (argv) => {
|
|
||||||
const rootDir = getRootDir(argv)
|
const rootDir = getRootDir(argv)
|
||||||
const nuxtConfigFile = getNuxtConfigFile(argv)
|
const nuxtConfigFile = getNuxtConfigFile(argv)
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ exports.loadNuxtConfig = (argv) => {
|
|||||||
|
|
||||||
if (existsSync(nuxtConfigFile)) {
|
if (existsSync(nuxtConfigFile)) {
|
||||||
delete require.cache[nuxtConfigFile]
|
delete require.cache[nuxtConfigFile]
|
||||||
options = esm(nuxtConfigFile)
|
options = _require(nuxtConfigFile)
|
||||||
if (!options) {
|
if (!options) {
|
||||||
options = {}
|
options = {}
|
||||||
}
|
}
|
5
packages/cli/src/index.js
Normal file
5
packages/cli/src/index.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export const start = () => import('./commands/start')
|
||||||
|
export const dev = () => import('./commands/dev')
|
||||||
|
|
||||||
|
export const build = () => import('./commands/build')
|
||||||
|
export const generate = () => import('./commands/generate')
|
11
packages/common/CHANGELOG.md
Normal file
11
packages/common/CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# 2.3.0 (2018-10-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Migrate Nuxt into monorepo
|
3
packages/common/package.js
Normal file
3
packages/common/package.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
build: true
|
||||||
|
}
|
15
packages/common/package.json
Normal file
15
packages/common/package.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "@nuxt/common",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"repository": "nuxt/nuxt.js",
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"main": "dist/common.js",
|
||||||
|
"dependencies": {
|
||||||
|
"consola": "^1.4.4",
|
||||||
|
"lodash": "^4.17.11",
|
||||||
|
"std-env": "^2.0.2"
|
||||||
|
}
|
||||||
|
}
|
4
packages/common/src/index.js
Normal file
4
packages/common/src/index.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export { default as Modes } from './modes'
|
||||||
|
export { default as NuxtConfig } from './nuxt.config'
|
||||||
|
export { default as Options } from './options'
|
||||||
|
export * from './utils'
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user