-
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
【Taro支持自定义postcss插件吗?我添加后未生效...】 #2678
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
CC @luckyadam |
项目等不及了,写了个替换脚本 更新了一下脚本 const path = require('path')
const fs = require('fs')
const shelljs = require('shelljs')
const { sftpPath } = require('../src/api/config')
function resolve(fakepath) {
return path.resolve(__dirname, '..', fakepath)
}
function update(rootpath) {
fs.readdir(resolve(rootpath), 'utf8', function(err, dirList) {
if (err) {
throw err
}
dirList.forEach(function(item) {
let stats = fs.statSync(resolve(`${rootpath}/${item}`))
if (stats.isDirectory()) {
// 文件夹
if (item === 'npm') return undefined
update(`${rootpath}/${item}`)
} else {
// 文件
if (stats.size > 200 * 1024) return undefined
fs.readFile(resolve(`${rootpath}/${item}`), 'utf8', function(err, file) {
if (err) {
throw err
}
// 文件
let newFile = ''
if (/\.json$/.test(item)) {
newFile = file.replace(/(['"]{1})([./]*assets\/images\/)/g, function($0, $1) {
return `${$1}${sftpPath}/ebank/images/`
})
} else if (/\.js$/.test(item)) {
newFile = file.replace(/(['"]{1})([./]*assets\/images\/)/g, function($0, $1) {
return `${$1}${sftpPath}/ebank/images/`
})
} else if (/\.wxss|\.css/.test(item)) {
newFile = file.replace(/(url\(['"]?)([./]*assets\/images\/)/g, function($0, $1) {
return `${$1}${sftpPath}/ebank/images/`
})
} else if (/\.wxml/.test(item)) {
newFile = file.replace(/(['"]{1})([./]*assets\/images\/)/g, function($0, $1) {
return `${$1}${sftpPath}/ebank/images/`
})
}
if (newFile) {
fs.writeFile(resolve(`${rootpath}/${item}`), newFile, 'utf8', function(err) {
if (err) {
console.log(err)
throw err
}
})
}
})
}
})
})
}
update('dist')
shelljs.rm('-rf', resolve('dist/assets/images')) |
@harrydengchao 我们尽快支持一下 🤣 |
@harrydengchao 是配置这里有问题
配置项的结构是与内置的 postcss 处理插件一样的 |
@luckyadam 非常感谢! 这是我的问题,很抱歉 |
@patchBig 目前 css 里面,我就是使用自己写的 postcss 插件处理的。 js 里面,用 babel 插件处理后,依然会被打包进去,所以 js 文件的引用,我是用 nodejs 脚本做的批量替换。以上 |
不是,只是个外挂脚本,单独跑一遍,替换源码 |
类似问题:#1550 #998
问题描述
在
weapp.module.postcss
中添加 postcss 插件,但是并没有生效复现步骤
[或者可以直接贴源代码,能贴文字就不要截图]

期望行为
编译时进入到
postcss-plugin-image-to-url
进行处理报错信息
编译没有进入到
postcss-plugin-image-to-url
中系统信息
The text was updated successfully, but these errors were encountered: