vue-cli-3 - 如何使用 TailwindCSS 为 vue-cli-3 项目配置 PurgeCSS?(包括响应类)
问题描述
我正在尝试部署一个 vue-cli-3 项目。我使用 TailwindCSS 并创建了一个vue.config.js
文件,它正在工作,但不包括响应类。我在 webpack.config.js 文件中使用提取器搜索了一个正则表达式,但它没有用。我应该怎么做才能让这个工作?
这是我的vue.config.js
文件
const PurgecssPlugin = require('purgecss-webpack-plugin')
const glob = require('glob-all')
const path = require('path')
module.exports = {
configureWebpack: {
// Merged into the final Webpack config
plugins: [
new PurgecssPlugin({
paths: glob.sync([
path.join(__dirname, './src/index.html'),
path.join(__dirname, './**/*.vue'),
path.join(__dirname, './src/**/*.js')
])
})
]
}
}
我应该把提取器数组放在哪里?
解决方案
更新您的配置如下:
const PurgecssPlugin = require('purgecss-webpack-plugin')
const glob = require('glob-all')
const path = require('path')
module.exports = {
configureWebpack: {
// Merged into the final Webpack config
plugins: [
new PurgecssPlugin({
paths: glob.sync([
path.join(__dirname, './src/index.html'),
path.join(__dirname, './src/**/*.vue'),
path.join(__dirname, './src/**/*.js')
]),
extractors: [
{
extractor: class TailwindExtractor {
static extract(content) {
return content.match(/[A-z0-9-_:\/]+/g) || [];
}
},
extensions: ['html', 'vue', 'js'],
},
],
})
]
}
}
另外,我注意到您使用'./**/*.vue'
的是故意还是错误的?
推荐阅读
- python - 如何在 PyQt5 中重置 UI
- android - 如果嵌套滚动视图结束,如何停用滚动父滚动视图?
- javascript - 如何在 React 中使用 POST 方法将对象添加到数据库?
- android - 在项目“应用程序”中,已解决的 Google Play 服务库依赖项依赖于另一个确切版本(例如“[1.3.1 ,2.3]”,
- r - 180 个嵌套条件在一个单独的文件中为我的数据框中的每一行创建一个新的 id 变量
- amazon-web-services - lambda Add-Permissions 上的 Localstack 404
- ios - 使用 trailingSwipeActionsConfigurationForRowAt 删除行时奇怪的缺少其他行问题
- google-cloud-dataflow - Java Apache Beam - 侧面输入问题
- python - 在创建三次样条变量之前或之后缩放数据?
- asp.net-mvc - 如何从多对一关系表中获取唯一记录