-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
从1.2.26 升级到 1.3.8 跨平台文件引用报错 #3791
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
看一下你的alias配置? |
alias: {
'@actions': path.resolve(__dirname, '..', 'src/actions'),
'@static': path.resolve(__dirname, '..', 'src/static'),
'@image': path.resolve(__dirname, '..', 'src/static/image'),
'@components': path.resolve(__dirname, '..', 'src/components'),
'@constants': path.resolve(__dirname, '..', 'src/constants'),
'@reducers': path.resolve(__dirname, '..', 'src/reducers'),
'@styles': path.resolve(__dirname, '..', 'src/styles'),
'@utils': path.resolve(__dirname, '..', 'src/utils'),
'@const': path.resolve(__dirname, '..', 'src/const'),
'@pages': path.resolve(__dirname, '..', 'src/pages')
}, |
const path = require('path')
console.log(path.resolve(__dirname, '..', 'src/styles/theme.scss'))
// NOTE 在 sass 中通过别名(@ 或 ~)引用需要指定路径
const sassImporter = function(url) {
if (url[0] === '~' && url[1] !== '/') {
return {
file: path.resolve(__dirname, '..', 'node_modules', url.substr(1))
}
}
const reg = /^@styles\/(.*)/
return {
file: reg.test(url) ? path.resolve(__dirname, '..', 'src/styles', url.match(reg)[1]) : url
}
}
const config = {
projectName: 'aiyomi-h5',
date: '2019-4-16',
designWidth: 750,
deviceRatio: {
'640': 2.34 / 2,
'750': 1,
'828': 1.81 / 2
},
sourceRoot: 'src',
outputRoot: 'dist',
plugins: {
babel: {
sourceMap: true,
presets: [
['env', {
modules: false
}]
],
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread'
]
},
sass: {
importer: sassImporter,
resource: path.resolve(__dirname, '..', 'src/styles/theme.scss'),
projectDirectory: path.resolve(__dirname, '..')
}
},
defineConstants: {
},
alias: {
'@actions': path.resolve(__dirname, '..', 'src/actions'),
'@static': path.resolve(__dirname, '..', 'src/static'),
'@image': path.resolve(__dirname, '..', 'src/static/image'),
'@components': path.resolve(__dirname, '..', 'src/components'),
'@constants': path.resolve(__dirname, '..', 'src/constants'),
'@reducers': path.resolve(__dirname, '..', 'src/reducers'),
'@styles': path.resolve(__dirname, '..', 'src/styles'),
'@utils': path.resolve(__dirname, '..', 'src/utils'),
'@const': path.resolve(__dirname, '..', 'src/const'),
'@pages': path.resolve(__dirname, '..', 'src/pages')
},
copy: {
patterns: [
],
options: {
}
},
weapp: {
module: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
}
},
pxtransform: {
enable: true,
config: {
}
},
url: {
enable: true,
config: {
limit: 10240 // 设定转换尺寸上限
}
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
}
},
h5: {
// NOTE H5 打包静态资源时带 hash 值,方便缓存、版本管理
publicPath: '/',
staticDirectory: 'static',
esnextModules: ['taro-ui'],
output: {
filename: 'js/[name].[hash].js',
chunkFilename: 'js/[name].[chunkhash].js'
},
imageUrlLoaderOption: {
limit: 5000,
name: 'static/images/[name].[hash].[ext]'
},
miniCssExtractPluginOption: {
filename: 'css/[name].[hash].css',
chunkFilename: 'css/[name].[chunkhash].css',
},
module: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
}
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
},
sassLoaderOption: {
importer: sassImporter
},
fontUrlLoaderOption: {
test: /\.(eot|ttf|svg|woff)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
}
]
}
}
}
module.exports = function (merge) {
if (process.env.NODE_ENV === 'development') {
return merge({}, config, require('./dev'))
}
return merge({}, config, require('./prod'))
} |
ok 我看下 |
(:з」∠) 好 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述
[问题描述:站在其它人的角度尽可能清晰地、简洁地把问题描述清楚]
升级Taro并更新项目依赖后,跨平台文件报错,报错
./.temp/pages/courseMain/courseMain.js Module not found: Can't resolve '@utils/methods' in 'E:\aiyomi-h5\.temp\pages\courseMain'
复现步骤
[复现问题的步骤]
taro update self
更新后本地taro
版本未更新,所以从新安装了最新版的yarn global add @tarojs/cli@latest
taro update project
更新项目依赖yarn dev:h5
之后跨平台文件编译报错,如下图期望行为
期望编译无问题
报错信息
系统信息
补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]
The text was updated successfully, but these errors were encountered: