vue + tailwindcss 1.x

1、先创建 vue 项目

vue create tailwind

2、创建完后,添加 tailwind css

# Using npm

npm install tailwindcss

# Using Yarn

yarn add tailwindcss

3、创建 css 文件

./assets/css/tailwind.css

4、添加 tailwind.css 内容

@tailwind base;

@tailwind components;

@tailwind utilities;

5、初始化 tailwind css

npx tailwind init

7、在根目录下创建 postcss.config.js

8、安装 postcss-purgecss

# Using npm

npm install @fullhuman/postcss-purgecss --save-dev

# Using yarn

yarn add @fullhuman/postcss-purgecss -D

9、配置 postcss.config.js

const purgecss = require('@fullhuman/postcss-purgecss')({

// Specify the paths to all of the template files in your project

content: [ './src/**/*.html', './src/**/*.vue', './src/**/*.jsx', // etc. ],

// Include any special characters you're using in this regular expression

defaultExtractor:content => content.match(/[\w-/:]+(?<!:)/g) || [] })

module.exports = { plugins: [ require('tailwindcss'), require('autoprefixer'), ...process.env.NODE_ENV === 'production' ? [purgecss] : [] ] }

Done!!!!

可以在 vue 下使用 tailwindcss 了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ## 框架和库的区别?> 框架(framework):一套完整的软件设计架构和**解决方案**。> > 库(lib...
    Rui_bdad阅读 2,973评论 1 4
  • jHipster - 微服务搭建 CC_简书[https://www.jianshu.com/u/be0d56c4...
    quanjj阅读 838评论 0 2
  • 33、JS中的本地存储 把一些信息存储在当前浏览器指定域下的某一个地方(存储到物理硬盘中)1、不能跨浏览器传输:在...
    萌妹撒阅读 2,104评论 0 2
  • 原文http://www.cnblogs.com/libin-1/p/6596810.html 版本号 vue-c...
    tengrl阅读 3,694评论 0 0
  • 前言 上一期中我们通过引入了插件实现了不少功能——样式抽离、公共模块提取、代码压缩等等;本期开始讲讲可能会用到的第...
    JasonWild阅读 1,823评论 0 8