mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
Handle publicPath
This commit is contained in:
parent
5a500b6735
commit
376362ec39
@ -83,6 +83,14 @@ export function options () {
|
||||
if (this.options.build && !Array.isArray(this.options.build.loaders)) extraDefaults.loaders = defaultsLoaders
|
||||
if (this.options.build && !Array.isArray(this.options.build.postcss)) extraDefaults.postcss = defaultsPostcss
|
||||
this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults)
|
||||
if (this.options.build.publicPath.indexOf('http') === 0) {
|
||||
// activate only in production mode
|
||||
if (this.dev) {
|
||||
this.options.build.publicPath = defaults.publicPath
|
||||
} else {
|
||||
this.options.nuxtStatic = false
|
||||
}
|
||||
}
|
||||
// Production, create server-renderer
|
||||
if (!this.dev) {
|
||||
const serverConfig = getWebpackServerConfig.call(this)
|
||||
|
@ -22,15 +22,6 @@ const defaults = {
|
||||
export default function () {
|
||||
const s = Date.now()
|
||||
/*
|
||||
** Update loaders config to add router.base path
|
||||
*/
|
||||
// this.options.build.loaders.forEach((config) => {
|
||||
// if (['file', 'url', 'file-loader', 'url-loader'].includes(config.loader)) {
|
||||
// config.query = config.query || {}
|
||||
// config.query.publicPath = urlJoin(this.options.router.base, '/_nuxt/')
|
||||
// }
|
||||
// })
|
||||
/*
|
||||
** Set variables
|
||||
*/
|
||||
this.options.generate = _.defaultsDeep(this.options.generate, defaults)
|
||||
@ -38,7 +29,7 @@ export default function () {
|
||||
var srcStaticPath = resolve(this.srcDir, 'static')
|
||||
var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist')
|
||||
var distPath = resolve(this.dir, this.options.generate.dir)
|
||||
var distNuxtPath = resolve(distPath, '_nuxt')
|
||||
var distNuxtPath = join(distPath, (this.options.build.publicPath.indexOf('http') === 0 ? '_nuxt' : this.options.build.publicPath))
|
||||
return co(function * () {
|
||||
/*
|
||||
** Launch build process
|
||||
|
@ -76,8 +76,8 @@ class Nuxt {
|
||||
this.renderer = null
|
||||
// For serving static/ files to /
|
||||
this.serveStatic = pify(serveStatic(resolve(this.srcDir, 'static')))
|
||||
// For serving .nuxt/dist/ files
|
||||
this._nuxtRegexp = /^\/_nuxt\//
|
||||
// For serving .nuxt/dist/ files (only when build.publicPath is not an URL)
|
||||
this.options.nuxtStatic = true
|
||||
this.serveStaticNuxt = pify(serveStatic(resolve(this.dir, '.nuxt', 'dist')))
|
||||
// Add this.Server Class
|
||||
this.Server = Server
|
||||
|
@ -28,7 +28,7 @@ export function * waitFor (ms) {
|
||||
}
|
||||
|
||||
export function urlJoin () {
|
||||
return [].slice.call(arguments).join('/').replace(/\/+/g, '/')
|
||||
return [].slice.call(arguments).join('/').replace(/\/+/g, '/').replace(':/', '://')
|
||||
}
|
||||
|
||||
export function promisifyRouteParams (fn) {
|
||||
|
@ -21,7 +21,7 @@ export default function ({ isClient, isServer }) {
|
||||
vendor: ['vue', 'vue-router', 'vue-meta']
|
||||
},
|
||||
output: {
|
||||
publicPath: urlJoin(this.options.router.base, '/_nuxt/')
|
||||
publicPath: (this.options.build.publicPath.indexOf('http') === 0 ? this.options.build.publicPath : urlJoin(this.options.router.base, this.options.build.publicPath))
|
||||
},
|
||||
performance: {
|
||||
hints: (this.dev ? false : 'warning')
|
||||
|
Loading…
Reference in New Issue
Block a user