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