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

fix(nvue): add file-loader

上级 d717f1d0
const path = require('path')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
module.exports = {
loader: 'file-loader',
options: {
publicPath (url, resourcePath, context) {
return '/' + normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
},
outputPath (url, resourcePath, context) {
return normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
}
}
}
const path = require('path') const fileLoader = require('./file-loader.js')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
const defaultOptions = { const defaultOptions = {
limit: -1, limit: -1,
fallback: { fallback: fileLoader
loader: 'file-loader',
options: {
publicPath (url, resourcePath, context) {
return '/' + normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
},
outputPath (url, resourcePath, context) {
return normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
}
}
}
} }
const inlineLimit = const inlineLimit =
...@@ -60,4 +46,4 @@ module.exports = { ...@@ -60,4 +46,4 @@ module.exports = {
} }
}, },
rewriteUrl rewriteUrl
} }
...@@ -11,7 +11,7 @@ const { ...@@ -11,7 +11,7 @@ const {
nvueHtmlPreprocessOptions, nvueHtmlPreprocessOptions,
getTemplatePath getTemplatePath
} = require('@dcloudio/uni-cli-shared') } = require('@dcloudio/uni-cli-shared')
const fileLoader = require('@dcloudio/uni-cli-shared/lib/file-loader')
const WebpackAppPlusNVuePlugin = process.env.UNI_USING_V3 const WebpackAppPlusNVuePlugin = process.env.UNI_USING_V3
? require('../packages/webpack-app-plus-plugin') ? require('../packages/webpack-app-plus-plugin')
: require('../packages/webpack-app-plus-nvue-plugin') : require('../packages/webpack-app-plus-nvue-plugin')
...@@ -109,13 +109,7 @@ if (process.env.NODE_ENV === 'development') { ...@@ -109,13 +109,7 @@ if (process.env.NODE_ENV === 'development') {
const rules = [{ const rules = [{
test: /\.(png|jpg|gif|ttf|eot|woff|woff2)$/i, test: /\.(png|jpg|gif|ttf|eot|woff|woff2)$/i,
use: [{ use: [fileLoader]
loader: 'file-loader',
options: {
publicPath: 'assets',
outputPath: 'assets'
}
}]
}, { }, {
test: path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'), test: path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
use: [{ use: [{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册