Skip to content

Commit

Permalink
Create postcss tailwindcss loader plugin for docusaurus
Browse files Browse the repository at this point in the history
  • Loading branch information
kvnxiao committed Nov 29, 2020
1 parent cccb2e5 commit 2019279
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 16 deletions.
1 change: 1 addition & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
favicon: 'img/favicon.ico',
organizationName: 'Discord4J',
projectName: 'Discord4J',
plugins: ['docusaurus-tailwindcss-loader'],
themeConfig: {
navbar: {
title: 'Discord4J',
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
"@docusaurus/preset-classic": "2.0.0-alpha.69",
"@mdx-js/react": "^1.6.21",
"clsx": "^1.1.1",
"docusaurus-tailwindcss-loader": "file:plugins/docusaurus-tailwindcss-loader",
"postcss": "^7.0.34",
"postcss-import": "^12.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1"
"react-dom": "^17.0.1",
"tailwindcss": "npm:@tailwindcss/postcss7-compat"
},
"browserslist": {
"production": [
Expand Down
34 changes: 34 additions & 0 deletions plugins/docusaurus-tailwindcss-loader/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = function (context, options) {
return {
name: 'postcss-tailwindcss-loader',
configureWebpack(config, isServer, utils) {
return {
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: require.resolve('postcss-loader'),
options: {
ident: 'postcss',
plugins: () => [
require('postcss-import'),
require('tailwindcss'),
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009',
},
stage: 4,
}),
],
},
},
],
},
],
},
}
},
}
}
4 changes: 4 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* work well for content-centric websites.
*/

@tailwind base;
@tailwind components;
@tailwind utilities;

/* You can override the default Infima variables here. */
:root {
--ifm-color-primary: #25c2a0;
Expand Down
11 changes: 11 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
purge: ['./src/**/*.html', './src/**/*.js', './src/**/*.tsx'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
Loading

0 comments on commit 2019279

Please sign in to comment.