Nuxt/packages/webpack/src/presets/assets.ts

38 lines
852 B
TypeScript
Raw Normal View History

import type { WebpackConfigContext } from '../utils/config'
import { fileName } from '../utils/config'
2020-09-02 12:27:27 +00:00
export function assets (ctx: WebpackConfigContext) {
ctx.config.module!.rules!.push(
2020-09-02 12:27:27 +00:00
{
test: /\.(png|jpe?g|gif|svg|webp)$/i,
use: [{
loader: 'url-loader',
options: {
...ctx.userConfig.loaders.imgUrl,
2020-09-02 12:27:27 +00:00
name: fileName(ctx, 'img')
}
}]
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
use: [{
loader: 'url-loader',
options: {
...ctx.userConfig.loaders.fontUrl,
2020-09-02 12:27:27 +00:00
name: fileName(ctx, 'font')
}
}]
},
{
test: /\.(webm|mp4|ogv)$/i,
use: [{
loader: 'file-loader',
options: {
...ctx.userConfig.loaders.file,
2020-09-02 12:27:27 +00:00
name: fileName(ctx, 'video')
}
}]
}
)
}