mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
feat: use understandable file names for analyze mode (#4014)
* feat: use understandable file names for analyze mode * test: asset name for analyze mode * refactor: add warning message for analyze mode * refactor: move analyze warning to builder * test: analyze warning message
This commit is contained in:
parent
8f06a187db
commit
0393bf781c
@ -59,6 +59,15 @@ export default class Builder {
|
|||||||
this.mfs = new MFS()
|
this.mfs = new MFS()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.options.build.analyze) {
|
||||||
|
this.nuxt.hook('build:done', () => {
|
||||||
|
consola.warn({
|
||||||
|
message: 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.',
|
||||||
|
badge: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 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())
|
||||||
|
@ -15,6 +15,16 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
|
|||||||
super(builder, { name: 'client', isServer: false })
|
super(builder, { name: 'client', isServer: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFileName(...args) {
|
||||||
|
if (this.options.build.analyze) {
|
||||||
|
const key = args[0]
|
||||||
|
if (['app', 'chunk'].includes(key)) {
|
||||||
|
return '[name].js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getFileName(...args)
|
||||||
|
}
|
||||||
|
|
||||||
env() {
|
env() {
|
||||||
return Object.assign(super.env(), {
|
return Object.assign(super.env(), {
|
||||||
'process.env.VUE_ENV': JSON.stringify('client'),
|
'process.env.VUE_ENV': JSON.stringify('client'),
|
||||||
|
18
test/fixtures/with-config/with-config.test.js
vendored
18
test/fixtures/with-config/with-config.test.js
vendored
@ -14,13 +14,19 @@ const hooks = [
|
|||||||
|
|
||||||
describe('with-config', () => {
|
describe('with-config', () => {
|
||||||
buildFixture('with-config', () => {
|
buildFixture('with-config', () => {
|
||||||
expect(consola.warn).toHaveBeenCalledTimes(1)
|
expect(consola.warn).toHaveBeenCalledTimes(2)
|
||||||
expect(consola.fatal).toHaveBeenCalledTimes(0)
|
expect(consola.fatal).toHaveBeenCalledTimes(0)
|
||||||
expect(consola.warn.mock.calls[0]).toMatchObject([{
|
expect(consola.warn.mock.calls).toMatchObject([
|
||||||
message: 'Found 2 plugins that match the configuration, suggest to specify extension:',
|
[{
|
||||||
additional: expect.stringContaining('plugins/test.json'),
|
message: 'Found 2 plugins that match the configuration, suggest to specify extension:',
|
||||||
badge: true
|
additional: expect.stringContaining('plugins/test.json'),
|
||||||
}])
|
badge: true
|
||||||
|
}],
|
||||||
|
[{
|
||||||
|
message: 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.',
|
||||||
|
badge: true
|
||||||
|
}]
|
||||||
|
])
|
||||||
expect(customCompressionMiddlewareFunctionName).toBe('damn')
|
expect(customCompressionMiddlewareFunctionName).toBe('damn')
|
||||||
}, hooks)
|
}, hooks)
|
||||||
})
|
})
|
||||||
|
@ -19,6 +19,11 @@ describe('with-config', () => {
|
|||||||
expect(html.includes('<h1>I have custom configurations</h1>')).toBe(true)
|
expect(html.includes('<h1>I have custom configurations</h1>')).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('/ (asset name for analyze mode)', async () => {
|
||||||
|
const { html } = await nuxt.renderRoute('/')
|
||||||
|
expect(html).toContain('<script src="/test/orion/app.js"')
|
||||||
|
})
|
||||||
|
|
||||||
test.skip('/ (global styles inlined)', async () => {
|
test.skip('/ (global styles inlined)', async () => {
|
||||||
const { html } = await nuxt.renderRoute('/')
|
const { html } = await nuxt.renderRoute('/')
|
||||||
expect(html).toContain('.global-css-selector')
|
expect(html).toContain('.global-css-selector')
|
||||||
|
Loading…
Reference in New Issue
Block a user