Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): prevent invalid css filenames in webpack output #8778

Merged
merged 6 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli/test/unit/__snapshots__/webpack.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ exports[`webpack nuxt webpack module.rules 1`] = `
\\"options\\": Object {
\\"esModule\\": false,
\\"limit\\": 1000,
\\"name\\": \\"img/[name].[contenthash:7].[ext]\\",
\\"name\\": \\"img/[contenthash:7].[ext]\\",
},
},
],
Expand All @@ -597,7 +597,7 @@ exports[`webpack nuxt webpack module.rules 1`] = `
\\"options\\": Object {
\\"esModule\\": false,
\\"limit\\": 1000,
\\"name\\": \\"fonts/[name].[contenthash:7].[ext]\\",
\\"name\\": \\"fonts/[contenthash:7].[ext]\\",
},
},
],
Expand All @@ -609,7 +609,7 @@ exports[`webpack nuxt webpack module.rules 1`] = `
\\"loader\\": \\"<nuxtDir>/node_modules/file-loader/dist/cjs.js\\",
\\"options\\": Object {
\\"esModule\\": false,
\\"name\\": \\"videos/[name].[contenthash:7].[ext]\\",
\\"name\\": \\"videos/[contenthash:7].[ext]\\",
},
},
],
Expand Down
8 changes: 4 additions & 4 deletions packages/config/src/config/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export default () => ({
// { isDev, isClient, isServer }
app: ({ isDev, isModern }) => isDev ? `[name]${isModern ? '.modern' : ''}.js` : `[contenthash:7]${isModern ? '.modern' : ''}.js`,
chunk: ({ isDev, isModern }) => isDev ? `[name]${isModern ? '.modern' : ''}.js` : `[contenthash:7]${isModern ? '.modern' : ''}.js`,
css: ({ isDev }) => isDev ? '[name].css' : '[name].[contenthash:7].css',
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[name].[contenthash:7].[ext]',
danielroe marked this conversation as resolved.
Show resolved Hide resolved
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[name].[contenthash:7].[ext]',
video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[name].[contenthash:7].[ext]'
css: ({ isDev }) => isDev ? '[name].css' : 'css/[contenthash:7].css',
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[contenthash:7].[ext]',
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[contenthash:7].[ext]',
video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[contenthash:7].[ext]'
},
loaders: {
file: { esModule: false },
Expand Down
8 changes: 4 additions & 4 deletions packages/config/test/config/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ describe('config: build', () => {
const env = { isDev: false }
expect(filenames.app(env)).toEqual('[contenthash:7].js')
expect(filenames.chunk(env)).toEqual('[contenthash:7].js')
expect(filenames.css(env)).toEqual('[name].[contenthash:7].css')
expect(filenames.img(env)).toEqual('img/[name].[contenthash:7].[ext]')
expect(filenames.font(env)).toEqual('fonts/[name].[contenthash:7].[ext]')
expect(filenames.video(env)).toEqual('videos/[name].[contenthash:7].[ext]')
expect(filenames.css(env)).toEqual('css/[contenthash:7].css')
expect(filenames.img(env)).toEqual('img/[contenthash:7].[ext]')
expect(filenames.font(env)).toEqual('fonts/[contenthash:7].[ext]')
expect(filenames.video(env)).toEqual('videos/[contenthash:7].[ext]')
})

test('should return modern filenames', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/dev/with-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('with-config', () => {
test('/ (preload fonts)', async () => {
const { html } = await nuxt.server.renderRoute('/')
expect(html).toMatch(
/<link rel="preload" href="\/test\/orion\/fonts\/roboto.[\w]{7}.woff2" as="font" type="font\/woff2" crossorigin/
/<link rel="preload" href="\/test\/orion\/roboto.fonts\/[\w]{7}.woff2" as="font" type="font\/woff2" crossorigin/
)
})

Expand Down