mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Copy all the static assests to .out
This commit is contained in:
parent
3fbccff936
commit
f602f6dc1e
1
bin/next
1
bin/next
|
@ -22,6 +22,7 @@ const commands = new Set([
|
|||
'init',
|
||||
'build',
|
||||
'start',
|
||||
'export',
|
||||
defaultCommand
|
||||
])
|
||||
|
||||
|
|
51
bin/next-export
Normal file
51
bin/next-export
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env node
|
||||
import { resolve, join } from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import parseArgs from 'minimist'
|
||||
import exportApp from '../server/export'
|
||||
import { printAndExit } from '../lib/utils'
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
||||
|
||||
const argv = parseArgs(process.argv.slice(2), {
|
||||
alias: {
|
||||
h: 'help'
|
||||
},
|
||||
boolean: ['h']
|
||||
})
|
||||
|
||||
if (argv.help) {
|
||||
console.log(`
|
||||
Description
|
||||
Exports the application for production deployment
|
||||
|
||||
Usage
|
||||
$ next export <dir>
|
||||
|
||||
<dir> represents where the compiled dist folder should go.
|
||||
If no directory is provided, the dist folder will be created in the current directory.
|
||||
You can set a custom folder in config https://github.com/zeit/next.js#custom-configuration, otherwise it will be created inside '.next'
|
||||
`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const dir = resolve(argv._[0] || '.')
|
||||
|
||||
// Check if pages dir exists and warn if not
|
||||
if (!existsSync(dir)) {
|
||||
printAndExit(`> No such directory exists as the project root: ${dir}`)
|
||||
}
|
||||
|
||||
if (!existsSync(join(dir, 'pages'))) {
|
||||
if (existsSync(join(dir, '..', 'pages'))) {
|
||||
printAndExit('> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?')
|
||||
}
|
||||
|
||||
printAndExit('> Couldn\'t find a `pages` directory. Please create one under the project root')
|
||||
}
|
||||
|
||||
exportApp(dir)
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
|
@ -118,6 +118,7 @@
|
|||
"nyc": "10.3.0",
|
||||
"react": "15.5.3",
|
||||
"react-dom": "15.5.3",
|
||||
"recursive-copy": "^2.0.6",
|
||||
"standard": "9.0.2",
|
||||
"wd": "1.2.0"
|
||||
},
|
||||
|
|
34
server/export.js
Normal file
34
server/export.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import del from 'del'
|
||||
import cp from 'recursive-copy'
|
||||
import mkdirp from 'mkdirp-then'
|
||||
import { resolve, join } from 'path'
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
|
||||
export default async function (dir) {
|
||||
const outDir = resolve(dir, '.out')
|
||||
const nextDir = resolve(dir, '.next')
|
||||
|
||||
if (!existsSync(nextDir)) {
|
||||
console.error('Build your with "next build" before running "next start".')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const buildId = readFileSync(join(nextDir, 'BUILD_ID'), 'utf8')
|
||||
const buildStats = require(join(nextDir, 'build-stats.json'))
|
||||
|
||||
// Initialize the output directory
|
||||
await del(outDir)
|
||||
await mkdirp(join(outDir, '_next', buildStats['app.js'].hash))
|
||||
await mkdirp(join(outDir, '_next', buildId))
|
||||
|
||||
// Copy files
|
||||
await cp(
|
||||
join(nextDir, 'app.js'),
|
||||
join(outDir, '_next', buildStats['app.js'].hash, 'app.js')
|
||||
)
|
||||
|
||||
await cp(
|
||||
join(nextDir, 'bundles', 'pages'),
|
||||
join(outDir, '_next', buildId, 'page')
|
||||
)
|
||||
}
|
140
yarn.lock
140
yarn.lock
|
@ -166,6 +166,10 @@ arr-flatten@^1.0.1:
|
|||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1"
|
||||
|
||||
array-differ@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031"
|
||||
|
||||
array-equal@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
|
||||
|
@ -480,7 +484,7 @@ babel-plugin-check-es2015-constants@^6.22.0:
|
|||
dependencies:
|
||||
babel-runtime "^6.22.0"
|
||||
|
||||
babel-plugin-istanbul@4.1.3:
|
||||
babel-plugin-istanbul@4.1.3, babel-plugin-istanbul@^4.0.0:
|
||||
version "4.1.3"
|
||||
resolved "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.3.tgz#6ee6280410dcf59c7747518c3dfd98680958f102"
|
||||
dependencies:
|
||||
|
@ -497,14 +501,6 @@ babel-plugin-istanbul@^3.0.0:
|
|||
object-assign "^4.1.0"
|
||||
test-exclude "^3.3.0"
|
||||
|
||||
babel-plugin-istanbul@^4.0.0:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.1.tgz#c12de0fc6fe42adfb16be56f1ad11e4a9782eca9"
|
||||
dependencies:
|
||||
find-up "^2.1.0"
|
||||
istanbul-lib-instrument "^1.6.2"
|
||||
test-exclude "^4.0.3"
|
||||
|
||||
babel-plugin-jest-hoist@^18.0.0:
|
||||
version "18.0.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-18.0.0.tgz#4150e70ecab560e6e7344adc849498072d34e12a"
|
||||
|
@ -1610,7 +1606,7 @@ deglob@^2.1.0:
|
|||
run-parallel "^1.1.2"
|
||||
uniq "^1.0.1"
|
||||
|
||||
del@2.2.2, del@^2.0.2:
|
||||
del@2.2.2, del@^2.0.2, del@^2.2.0:
|
||||
version "2.2.2"
|
||||
resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8"
|
||||
dependencies:
|
||||
|
@ -1743,6 +1739,10 @@ elliptic@^6.0.0:
|
|||
minimalistic-assert "^1.0.0"
|
||||
minimalistic-crypto-utils "^1.0.0"
|
||||
|
||||
emitter-mixin@0.0.3:
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/emitter-mixin/-/emitter-mixin-0.0.3.tgz#5948cb286f2e48edc3b251a7cfc1f7883396d65c"
|
||||
|
||||
emojis-list@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389"
|
||||
|
@ -1776,7 +1776,7 @@ entities@^1.1.1, entities@~1.1.1:
|
|||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
|
||||
|
||||
"errno@>=0.1.1 <0.2.0-0", errno@^0.1.3:
|
||||
"errno@>=0.1.1 <0.2.0-0", errno@^0.1.2, errno@^0.1.3:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d"
|
||||
dependencies:
|
||||
|
@ -2407,7 +2407,7 @@ globby@^5.0.0:
|
|||
pify "^2.0.0"
|
||||
pinkie-promise "^2.0.0"
|
||||
|
||||
graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
|
||||
graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6:
|
||||
version "4.1.11"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
|
||||
|
||||
|
@ -2860,39 +2860,21 @@ istanbul-api@^1.1.0-alpha.1:
|
|||
mkdirp "^0.5.1"
|
||||
once "^1.4.0"
|
||||
|
||||
istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.0.2:
|
||||
istanbul-lib-coverage@^1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz#87a0c015b6910651cb3b184814dfb339337e25e1"
|
||||
|
||||
istanbul-lib-coverage@^1.1.0:
|
||||
istanbul-lib-coverage@^1.0.2, istanbul-lib-coverage@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.0.tgz#caca19decaef3525b5d6331d701f3f3b7ad48528"
|
||||
|
||||
istanbul-lib-hook@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.0.5.tgz#6ca3d16d60c5f4082da39f7c5cd38ea8a772b88e"
|
||||
dependencies:
|
||||
append-transform "^0.4.0"
|
||||
|
||||
istanbul-lib-hook@^1.0.6:
|
||||
istanbul-lib-hook@^1.0.5, istanbul-lib-hook@^1.0.6:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-1.0.6.tgz#c0866d1e81cf2d5319249510131fc16dee49231f"
|
||||
dependencies:
|
||||
append-transform "^0.4.0"
|
||||
|
||||
istanbul-lib-instrument@^1.1.1, istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.6.2, istanbul-lib-instrument@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.0.tgz#b8e0dc25709bb44e17336ab47b7bb5c97c23f659"
|
||||
dependencies:
|
||||
babel-generator "^6.18.0"
|
||||
babel-template "^6.16.0"
|
||||
babel-traverse "^6.18.0"
|
||||
babel-types "^6.18.0"
|
||||
babylon "^6.13.0"
|
||||
istanbul-lib-coverage "^1.0.2"
|
||||
semver "^5.3.0"
|
||||
|
||||
istanbul-lib-instrument@^1.7.1:
|
||||
istanbul-lib-instrument@^1.1.1, istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.0, istanbul-lib-instrument@^1.7.1:
|
||||
version "1.7.1"
|
||||
resolved "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.1.tgz#169e31bc62c778851a99439dd99c3cc12184d360"
|
||||
dependencies:
|
||||
|
@ -2904,16 +2886,7 @@ istanbul-lib-instrument@^1.7.1:
|
|||
istanbul-lib-coverage "^1.1.0"
|
||||
semver "^5.3.0"
|
||||
|
||||
istanbul-lib-report@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.0.0.tgz#d83dac7f26566b521585569367fe84ccfc7aaecb"
|
||||
dependencies:
|
||||
istanbul-lib-coverage "^1.0.2"
|
||||
mkdirp "^0.5.1"
|
||||
path-parse "^1.0.5"
|
||||
supports-color "^3.1.2"
|
||||
|
||||
istanbul-lib-report@^1.1.0:
|
||||
istanbul-lib-report@^1.0.0, istanbul-lib-report@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-1.1.0.tgz#444c4ecca9afa93cf584f56b10f195bf768c0770"
|
||||
dependencies:
|
||||
|
@ -2922,16 +2895,7 @@ istanbul-lib-report@^1.1.0:
|
|||
path-parse "^1.0.5"
|
||||
supports-color "^3.1.2"
|
||||
|
||||
istanbul-lib-source-maps@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.1.1.tgz#f8c8c2e8f2160d1d91526d97e5bd63b2079af71c"
|
||||
dependencies:
|
||||
istanbul-lib-coverage "^1.0.2"
|
||||
mkdirp "^0.5.1"
|
||||
rimraf "^2.4.4"
|
||||
source-map "^0.5.3"
|
||||
|
||||
istanbul-lib-source-maps@^1.2.0:
|
||||
istanbul-lib-source-maps@^1.1.1, istanbul-lib-source-maps@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.0.tgz#8c7706d497e26feeb6af3e0c28fd5b0669598d0e"
|
||||
dependencies:
|
||||
|
@ -2941,13 +2905,7 @@ istanbul-lib-source-maps@^1.2.0:
|
|||
rimraf "^2.6.1"
|
||||
source-map "^0.5.3"
|
||||
|
||||
istanbul-reports@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.0.2.tgz#4e8366abe6fa746cc1cd6633f108de12cc6ac6fa"
|
||||
dependencies:
|
||||
handlebars "^4.0.3"
|
||||
|
||||
istanbul-reports@^1.1.0:
|
||||
istanbul-reports@^1.0.2, istanbul-reports@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-1.1.0.tgz#1ef3b795889219cfb5fad16365f6ce108d5f8c66"
|
||||
dependencies:
|
||||
|
@ -3252,6 +3210,10 @@ jsx-ast-utils@^1.3.4:
|
|||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1"
|
||||
|
||||
junk@^1.0.1:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/junk/-/junk-1.0.3.tgz#87be63488649cbdca6f53ab39bec9ccd2347f592"
|
||||
|
||||
kew@^0.7.0:
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b"
|
||||
|
@ -3494,6 +3456,15 @@ makeerror@1.0.x:
|
|||
dependencies:
|
||||
tmpl "1.0.x"
|
||||
|
||||
maximatch@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/maximatch/-/maximatch-0.1.0.tgz#86cd8d6b04c9f307c05a6b9419906d0360fb13a2"
|
||||
dependencies:
|
||||
array-differ "^1.0.0"
|
||||
array-union "^1.0.1"
|
||||
arrify "^1.0.0"
|
||||
minimatch "^3.0.0"
|
||||
|
||||
md5-file@3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/md5-file/-/md5-file-3.1.1.tgz#db3c92c09bbda5c2de883fa5490dd711fddbbab9"
|
||||
|
@ -4026,7 +3997,7 @@ performance-now@^0.2.0:
|
|||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5"
|
||||
|
||||
pify@^2.0.0:
|
||||
pify@^2.0.0, pify@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
|
||||
|
||||
|
@ -4061,11 +4032,11 @@ pkg-dir@^1.0.0:
|
|||
dependencies:
|
||||
find-up "^1.0.0"
|
||||
|
||||
pkg-up@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-1.0.0.tgz#3e08fb461525c4421624a33b9f7e6d0af5b05a26"
|
||||
pkg-up@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f"
|
||||
dependencies:
|
||||
find-up "^1.0.0"
|
||||
find-up "^2.1.0"
|
||||
|
||||
platform@^1.3.3:
|
||||
version "1.3.4"
|
||||
|
@ -4109,7 +4080,7 @@ progress@^1.1.8:
|
|||
version "1.1.8"
|
||||
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"
|
||||
|
||||
promise@^7.1.1:
|
||||
promise@^7.0.1, promise@^7.1.1:
|
||||
version "7.1.1"
|
||||
resolved "https://registry.yarnpkg.com/promise/-/promise-7.1.1.tgz#489654c692616b8aa55b0724fa809bb7db49c5bf"
|
||||
dependencies:
|
||||
|
@ -4280,6 +4251,21 @@ rechoir@^0.6.2:
|
|||
dependencies:
|
||||
resolve "^1.1.6"
|
||||
|
||||
recursive-copy@^2.0.6:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/recursive-copy/-/recursive-copy-2.0.6.tgz#d590f9eb5f165b96a1b80bc8f9cbcb5c6f9c89e9"
|
||||
dependencies:
|
||||
del "^2.2.0"
|
||||
emitter-mixin "0.0.3"
|
||||
errno "^0.1.2"
|
||||
graceful-fs "^4.1.4"
|
||||
junk "^1.0.1"
|
||||
maximatch "^0.1.0"
|
||||
mkdirp "^0.5.1"
|
||||
pify "^2.3.0"
|
||||
promise "^7.0.1"
|
||||
slash "^1.0.0"
|
||||
|
||||
redbox-react@^1.2.5:
|
||||
version "1.3.6"
|
||||
resolved "https://registry.yarnpkg.com/redbox-react/-/redbox-react-1.3.6.tgz#70314c57c066257eb70b0a24dc794b5cef4f1c4e"
|
||||
|
@ -4453,7 +4439,7 @@ right-align@^0.1.1:
|
|||
dependencies:
|
||||
align-text "^0.1.1"
|
||||
|
||||
rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.4.4, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:
|
||||
rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d"
|
||||
dependencies:
|
||||
|
@ -4605,18 +4591,12 @@ source-list-map@^1.1.1:
|
|||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-1.1.1.tgz#1a33ac210ca144d1e561f906ebccab5669ff4cb4"
|
||||
|
||||
source-map-support@0.4.15:
|
||||
source-map-support@0.4.15, source-map-support@^0.4.2:
|
||||
version "0.4.15"
|
||||
resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1"
|
||||
dependencies:
|
||||
source-map "^0.5.6"
|
||||
|
||||
source-map-support@^0.4.2:
|
||||
version "0.4.14"
|
||||
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef"
|
||||
dependencies:
|
||||
source-map "^0.5.6"
|
||||
|
||||
source-map@0.5.6, source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.3:
|
||||
version "0.5.6"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
|
||||
|
@ -4885,16 +4865,6 @@ test-exclude@^3.3.0:
|
|||
read-pkg-up "^1.0.1"
|
||||
require-main-filename "^1.0.1"
|
||||
|
||||
test-exclude@^4.0.3:
|
||||
version "4.0.3"
|
||||
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.0.3.tgz#86a13ce3effcc60e6c90403cf31a27a60ac6c4e7"
|
||||
dependencies:
|
||||
arrify "^1.0.1"
|
||||
micromatch "^2.3.11"
|
||||
object-assign "^4.1.0"
|
||||
read-pkg-up "^1.0.1"
|
||||
require-main-filename "^1.0.1"
|
||||
|
||||
test-exclude@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.npmjs.org/test-exclude/-/test-exclude-4.1.0.tgz#04ca70b7390dd38c98d4a003a173806ca7991c91"
|
||||
|
|
Loading…
Reference in a new issue