提交 460d112e 编写于 作者: fxy060608's avatar fxy060608

fix(v3): url-loader

上级 dc953f72
...@@ -3,6 +3,7 @@ const webpack = require('webpack') ...@@ -3,6 +3,7 @@ const webpack = require('webpack')
const { const {
getMainEntry, getMainEntry,
isInHBuilderX,
getPlatformCompiler getPlatformCompiler
} = require('@dcloudio/uni-cli-shared') } = require('@dcloudio/uni-cli-shared')
...@@ -144,16 +145,23 @@ const v3 = { ...@@ -144,16 +145,23 @@ const v3 = {
const isAppService = !!vueOptions.pluginOptions['uni-app-plus']['service'] const isAppService = !!vueOptions.pluginOptions['uni-app-plus']['service']
const isAppView = !!vueOptions.pluginOptions['uni-app-plus']['view'] const isAppView = !!vueOptions.pluginOptions['uni-app-plus']['view']
const fileLoaderOptions = isInHBuilderX ? {
emitFile: isAppView,
name: '[path][name].[ext]',
context: process.env.UNI_INPUT_DIR
} : {
emitFile: isAppView,
outputPath (url, resourcePath, context) {
return path.relative(process.env.UNI_INPUT_DIR, resourcePath)
}
}
// 处理静态资源 // 处理静态资源
webpackConfig.module webpackConfig.module
.rule('svg') .rule('svg')
.use('file-loader') .use('file-loader')
.options({ .options(fileLoaderOptions)
emitFile: isAppView,
outputPath (url, resourcePath, context) {
return path.relative(process.env.UNI_INPUT_DIR, resourcePath)
}
})
const staticTypes = ['images', 'media', 'fonts'] const staticTypes = ['images', 'media', 'fonts']
staticTypes.forEach(staticType => { staticTypes.forEach(staticType => {
webpackConfig.module webpackConfig.module
...@@ -164,12 +172,7 @@ const v3 = { ...@@ -164,12 +172,7 @@ const v3 = {
limit: 1, limit: 1,
fallback: { fallback: {
loader: 'file-loader', loader: 'file-loader',
options: { options: fileLoaderOptions
emitFile: isAppView,
outputPath (url, resourcePath, context) {
return path.relative(process.env.UNI_INPUT_DIR, resourcePath)
}
}
} }
})) }))
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册