feat: support functional filenames (#3787)

This commit is contained in:
Clark Du 2018-08-22 16:08:51 +01:00 committed by Sébastien Chopin
parent 8230354d1b
commit 3612ecd435
2 changed files with 16 additions and 1 deletions

View File

@ -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) {

View File

@ -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