mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
feat: support functional filenames (#3787)
This commit is contained in:
parent
8230354d1b
commit
3612ecd435
@ -46,6 +46,10 @@ export default class WebpackBaseConfig {
|
|||||||
getFileName(name) {
|
getFileName(name) {
|
||||||
let fileName = this.options.build.filenames[name]
|
let fileName = this.options.build.filenames[name]
|
||||||
|
|
||||||
|
if (typeof fileName === 'function') {
|
||||||
|
fileName = fileName(name)
|
||||||
|
}
|
||||||
|
|
||||||
// Don't use hashes when watching
|
// Don't use hashes when watching
|
||||||
// https://github.com/webpack/webpack/issues/1914#issuecomment-174171709
|
// https://github.com/webpack/webpack/issues/1914#issuecomment-174171709
|
||||||
if (this.options.dev) {
|
if (this.options.dev) {
|
||||||
|
@ -6,6 +6,7 @@ const url = route => 'http://localhost:' + port + route
|
|||||||
let nuxt = null
|
let nuxt = null
|
||||||
let builder = null
|
let builder = null
|
||||||
let transpile = null
|
let transpile = null
|
||||||
|
let appFileName = null
|
||||||
|
|
||||||
describe('basic dev', () => {
|
describe('basic dev', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
@ -14,14 +15,20 @@ describe('basic dev', () => {
|
|||||||
debug: true,
|
debug: true,
|
||||||
buildDir: '.nuxt-dev',
|
buildDir: '.nuxt-dev',
|
||||||
build: {
|
build: {
|
||||||
|
filenames: {
|
||||||
|
app: () => {
|
||||||
|
return 'test-app.[contenthash].js'
|
||||||
|
}
|
||||||
|
},
|
||||||
transpile: [
|
transpile: [
|
||||||
'vue\\.test\\.js',
|
'vue\\.test\\.js',
|
||||||
/vue-test/
|
/vue-test/
|
||||||
],
|
],
|
||||||
extend({ module: { rules } }, { isClient }) {
|
extend({ module: { rules }, output: { filename } }, { isClient }) {
|
||||||
if (isClient) {
|
if (isClient) {
|
||||||
const babelLoader = rules.find(loader => loader.test.test('.jsx'))
|
const babelLoader = rules.find(loader => loader.test.test('.jsx'))
|
||||||
transpile = file => !babelLoader.exclude(file)
|
transpile = file => !babelLoader.exclude(file)
|
||||||
|
appFileName = filename
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,6 +52,10 @@ describe('basic dev', () => {
|
|||||||
expect(transpile('node_modules/test.vue.js')).toBe(true)
|
expect(transpile('node_modules/test.vue.js')).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Config: build.filenames as function', () => {
|
||||||
|
expect(appFileName).toBe('test-app.js')
|
||||||
|
})
|
||||||
|
|
||||||
test('/stateless', async () => {
|
test('/stateless', async () => {
|
||||||
const window = await nuxt.renderAndGetWindow(url('/stateless'))
|
const window = await nuxt.renderAndGetWindow(url('/stateless'))
|
||||||
const html = window.document.body.innerHTML
|
const html = window.document.body.innerHTML
|
||||||
|
Loading…
Reference in New Issue
Block a user