mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
parent
cd1fc6277f
commit
fc5fb58c85
@ -8,7 +8,6 @@ export default () => ({
|
||||
fallback: '200.html',
|
||||
crawler: true,
|
||||
manifest: true,
|
||||
nojekyll: true,
|
||||
cache: {
|
||||
ignore: [],
|
||||
globbyOptions: {
|
||||
|
@ -221,7 +221,6 @@ Object {
|
||||
"fallback": "200.html",
|
||||
"interval": 0,
|
||||
"manifest": true,
|
||||
"nojekyll": true,
|
||||
"routes": Array [],
|
||||
"staticAssets": Object {
|
||||
"base": "/_nuxt/static",
|
||||
|
@ -196,7 +196,6 @@ Object {
|
||||
"fallback": "200.html",
|
||||
"interval": 0,
|
||||
"manifest": true,
|
||||
"nojekyll": true,
|
||||
"routes": Array [],
|
||||
"staticAssets": Object {
|
||||
"base": undefined,
|
||||
@ -585,7 +584,6 @@ Object {
|
||||
"fallback": "200.html",
|
||||
"interval": 0,
|
||||
"manifest": true,
|
||||
"nojekyll": true,
|
||||
"routes": Array [],
|
||||
"staticAssets": Object {
|
||||
"base": undefined,
|
||||
|
@ -267,10 +267,8 @@ export default class Generator {
|
||||
|
||||
// Add .nojekyll file to let GitHub Pages add the _nuxt/ folder
|
||||
// https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/
|
||||
if (this.options.generate.nojekyll) {
|
||||
const nojekyllPath = path.resolve(this.distPath, '.nojekyll')
|
||||
await fsExtra.writeFile(nojekyllPath, '')
|
||||
}
|
||||
|
||||
await this.nuxt.callHook('generate:distCopied', this)
|
||||
await this.nuxt.callHook('export:distCopied', this)
|
||||
|
@ -182,7 +182,6 @@ describe('generator: initialize', () => {
|
||||
test('should initialize destination folder', async () => {
|
||||
const nuxt = createNuxt()
|
||||
nuxt.options.generate.fallback = 'fallback.html'
|
||||
nuxt.options.generate.nojekyll = true
|
||||
const generator = new Generator(nuxt)
|
||||
fsExtra.exists.mockReturnValueOnce(false)
|
||||
|
||||
|
1
packages/types/config/generate.d.ts
vendored
1
packages/types/config/generate.d.ts
vendored
@ -18,7 +18,6 @@ export interface NuxtOptionsGenerate {
|
||||
exclude?: RegExp[]
|
||||
fallback?: string | boolean
|
||||
interval?: number
|
||||
nojekyll?: boolean
|
||||
routes?: NuxtOptionsGenerateRoute[] | NuxtOptionsGenerateRoutesFunction | NuxtOptionsGenerateRoutesFunctionWithCallback
|
||||
subFolders?: boolean
|
||||
cache?: false | {
|
||||
|
39
packages/types/config/module.d.ts
vendored
39
packages/types/config/module.d.ts
vendored
@ -6,8 +6,6 @@
|
||||
|
||||
import { Configuration as WebpackConfiguration } from 'webpack'
|
||||
import { NuxtOptionsLoaders } from './build'
|
||||
import { NuxtRouteConfig } from './router'
|
||||
import { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||
import { NuxtOptions } from '.'
|
||||
|
||||
interface ExtendFunctionContext {
|
||||
@ -19,43 +17,10 @@ interface ExtendFunctionContext {
|
||||
loaders: NuxtOptionsLoaders
|
||||
}
|
||||
|
||||
export interface ModuleTemplateConfig {
|
||||
src: string,
|
||||
fileName?: string
|
||||
filename?: string
|
||||
options?: Record<string, any>
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface ModulePluginTemplateConfig extends ModuleTemplateConfig {
|
||||
ssr?: boolean
|
||||
mode?: 'all' | 'client' | 'server'
|
||||
}
|
||||
|
||||
export interface ModuleTemplateDest {
|
||||
src: string
|
||||
dst: string
|
||||
options?: Record<string, any>
|
||||
}
|
||||
|
||||
export type ModuleTemplate = ModuleTemplateConfig | string
|
||||
export type ModulePluginTemplate = ModulePluginTemplateConfig | string
|
||||
|
||||
type ExtendRoutesFunction = (routes: NuxtRouteConfig[], resolve: (...pathSegments: string[]) => string) => void
|
||||
type ExtendBuildFunction = (config: WebpackConfiguration, ctx: ExtendFunctionContext) => void
|
||||
type ExtendFunction = (config: WebpackConfiguration, ctx: ExtendFunctionContext) => void
|
||||
|
||||
interface ModuleThis {
|
||||
addTemplate(template: ModuleTemplate): ModuleTemplateDest
|
||||
addPlugin(template: ModulePluginTemplate): void
|
||||
addLayout(template: ModuleTemplate, name?: string): void
|
||||
addErrorLayout (dst: string): void
|
||||
addServerMiddleware (middleware: NuxtOptionsServerMiddleware): void
|
||||
extendBuild(fn: ExtendBuildFunction): void
|
||||
extendRoutes(fn: ExtendRoutesFunction): void
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
requireModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise<any>
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
addModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise<any>
|
||||
extendBuild(fn: ExtendFunction): void
|
||||
options: NuxtOptions
|
||||
nuxt: any // TBD
|
||||
[key: string]: any // TBD
|
||||
|
@ -47,7 +47,6 @@
|
||||
"vue-loader": "^15.9.7",
|
||||
"vue-style-loader": "^4.1.3",
|
||||
"vue-template-compiler": "^2.6.12",
|
||||
"watchpack": "^2.1.1",
|
||||
"webpack": "^4.46.0",
|
||||
"webpack-bundle-analyzer": "^4.4.1",
|
||||
"webpack-dev-middleware": "^4.2.0",
|
||||
|
@ -17,7 +17,6 @@ import { TARGETS, isUrl, urlJoin, getPKG, tryResolve, requireModule, resolveModu
|
||||
import PerfLoader from '../utils/perf-loader'
|
||||
import StyleLoader from '../utils/style-loader'
|
||||
import WarningIgnorePlugin from '../plugins/warning-ignore'
|
||||
import { Watchpack2Plugin } from '../plugins/watchpack'
|
||||
import { reservedVueTags } from '../utils/reserved-tags'
|
||||
|
||||
export default class WebpackBaseConfig {
|
||||
@ -479,8 +478,6 @@ export default class WebpackBaseConfig {
|
||||
}))
|
||||
}
|
||||
|
||||
plugins.push(new Watchpack2Plugin())
|
||||
|
||||
return plugins
|
||||
}
|
||||
|
||||
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Base: https://github.com/webpack/webpack/blob/v4.46.0/lib/node/NodeWatchFileSystem.js (Tobias Koppers @sokra)
|
||||
*/
|
||||
import Watchpack from 'watchpack'
|
||||
import objectToMap from 'webpack/lib/util/objectToMap'
|
||||
|
||||
export class Watchpack2Plugin {
|
||||
apply (compiler) {
|
||||
if (compiler.watchFileSystem && compiler.watchFileSystem.watcher) {
|
||||
compiler.watchFileSystem.watcher.close()
|
||||
}
|
||||
compiler.watchFileSystem = new NodeWatchFileSystem(
|
||||
compiler.inputFileSystem
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export class NodeWatchFileSystem {
|
||||
constructor (inputFileSystem) {
|
||||
this.inputFileSystem = inputFileSystem
|
||||
this.watcherOptions = {
|
||||
aggregateTimeout: 0
|
||||
}
|
||||
this.watcher = new Watchpack(this.watcherOptions)
|
||||
}
|
||||
|
||||
watch (files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
||||
if (!Array.isArray(files)) {
|
||||
throw new TypeError("Invalid arguments: 'files'")
|
||||
}
|
||||
if (!Array.isArray(dirs)) {
|
||||
throw new TypeError("Invalid arguments: 'dirs'")
|
||||
}
|
||||
if (!Array.isArray(missing)) {
|
||||
throw new TypeError("Invalid arguments: 'missing'")
|
||||
}
|
||||
if (typeof callback !== 'function') {
|
||||
throw new TypeError("Invalid arguments: 'callback'")
|
||||
}
|
||||
if (typeof startTime !== 'number' && startTime) {
|
||||
throw new Error("Invalid arguments: 'startTime'")
|
||||
}
|
||||
if (typeof options !== 'object') {
|
||||
throw new TypeError("Invalid arguments: 'options'")
|
||||
}
|
||||
if (typeof callbackUndelayed !== 'function' && callbackUndelayed) {
|
||||
throw new Error("Invalid arguments: 'callbackUndelayed'")
|
||||
}
|
||||
const oldWatcher = this.watcher
|
||||
this.watcher = new Watchpack(options)
|
||||
|
||||
if (callbackUndelayed) {
|
||||
this.watcher.once('change', callbackUndelayed)
|
||||
}
|
||||
const cachedFiles = files
|
||||
const cachedDirs = dirs
|
||||
this.watcher.once('aggregated', (_changes, _removals) => {
|
||||
const removals = Array.from(_removals)
|
||||
const changes = Array.from(_changes).concat(removals)
|
||||
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
||||
this.inputFileSystem.purge(changes)
|
||||
}
|
||||
const times = objectToMap(this.watcher.getTimes())
|
||||
files = new Set(files)
|
||||
dirs = new Set(dirs)
|
||||
missing = new Set(missing)
|
||||
callback(
|
||||
null,
|
||||
changes.filter(file => files.has(file)).sort(),
|
||||
changes.filter(file => dirs.has(file)).sort(),
|
||||
changes.filter(file => missing.has(file)).sort(),
|
||||
times,
|
||||
times,
|
||||
new Set(removals.filter(file => files.has(file)))
|
||||
)
|
||||
})
|
||||
|
||||
this.watcher.watch(
|
||||
cachedFiles.concat(missing),
|
||||
cachedDirs.concat(missing),
|
||||
startTime
|
||||
)
|
||||
|
||||
if (oldWatcher) {
|
||||
oldWatcher.close()
|
||||
}
|
||||
return {
|
||||
close: () => {
|
||||
if (this.watcher) {
|
||||
this.watcher.close()
|
||||
this.watcher = null
|
||||
}
|
||||
},
|
||||
pause: () => {
|
||||
if (this.watcher) {
|
||||
this.watcher.pause()
|
||||
}
|
||||
},
|
||||
getFileTimestamps: () => {
|
||||
if (this.watcher) {
|
||||
return objectToMap(this.watcher.getTimes())
|
||||
} else {
|
||||
return new Map()
|
||||
}
|
||||
},
|
||||
getContextTimestamps: () => {
|
||||
if (this.watcher) {
|
||||
return objectToMap(this.watcher.getTimes())
|
||||
} else {
|
||||
return new Map()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
yarn.lock
13
yarn.lock
@ -6552,11 +6552,6 @@ glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@^5.1.1, glob-parent@~5.1.0:
|
||||
dependencies:
|
||||
is-glob "^4.0.1"
|
||||
|
||||
glob-to-regexp@^0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
|
||||
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==
|
||||
|
||||
glob@7.1.6:
|
||||
version "7.1.6"
|
||||
resolved "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
|
||||
@ -13358,14 +13353,6 @@ watchpack@^1.7.4:
|
||||
chokidar "^3.4.1"
|
||||
watchpack-chokidar2 "^2.0.1"
|
||||
|
||||
watchpack@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.npmjs.org/watchpack/-/watchpack-2.1.1.tgz#e99630550fca07df9f90a06056987baa40a689c7"
|
||||
integrity sha512-Oo7LXCmc1eE1AjyuSBmtC3+Wy4HcV8PxWh2kP6fOl8yTlNS7r0K9l1ao2lrrUza7V39Y3D/BbJgY8VeSlc5JKw==
|
||||
dependencies:
|
||||
glob-to-regexp "^0.4.1"
|
||||
graceful-fs "^4.1.2"
|
||||
|
||||
wcwidth@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
|
||||
|
Loading…
Reference in New Issue
Block a user