2022-12-11 21:44:52 +00:00
|
|
|
import type { WebpackConfigContext } from '../utils/config'
|
|
|
|
import { fileName } from '../utils/config'
|
2020-09-02 12:27:27 +00:00
|
|
|
|
|
|
|
export function assets (ctx: WebpackConfigContext) {
|
2022-08-26 15:47:29 +00:00
|
|
|
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: {
|
2023-07-24 19:46:09 +00:00
|
|
|
...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: {
|
2023-07-24 19:46:09 +00:00
|
|
|
...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: {
|
2023-07-24 19:46:09 +00:00
|
|
|
...ctx.userConfig.loaders.file,
|
2020-09-02 12:27:27 +00:00
|
|
|
name: fileName(ctx, 'video')
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|