Comments (6)
In my repo, I add Tailwind CSS after, just for testing install without plugin.
I think the "easy way" to add prism.js with Tailwind is to create a css file with /* purgecss start ignore */
and /* purgecss end ignore */
tags.
I you want to use tomorrow theme for example, locate prism-tomorrow.css
in node_modules/prism/theme, copy all content and create a new file in your assets folder.
In /scr/css/tomorrow.css
:
/* purgecss start ignore */
/**
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
* Based on https://github.com/chriskempson/tomorrow-theme
* @author Rose Pritchard
*/
code[class*="language-"],
pre[class*="language-"] {
color: #ccc;
background: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
...
/* purgecss end ignore */
And import this file in your main.js
file.
You can find more theme here: https://github.com/PrismJS/prism-themes
from gridsome-plugin-remark-prismjs-all.
Hello,
The problem is the use of prism.js with TailwindCSS and PurgeCSS.
In development mode, purgeCSS is not used: you can see the syntax highlighting.
But in production mode, purgeCSS is use...
With the plugin gridsome-plugin-remark-shiki, it is not a problem: the style is directely injected in the code.
<span style="color: #88C0D0">getHighlighter</span>
In order to keep safe the syntax highlighting, you must adapt your postcss.config.js
For example:
const join = require("path").join;
const tailwindJS = join(__dirname, "tailwind.js");
const purgecss = require("@fullhuman/postcss-purgecss");
class TailwindExtractor {
static extract(content) {
return content.match(/[A-Za-z0-9-_:\/]+/g) || [];
}
}
const plugins = [require("tailwindcss")(tailwindJS), require("autoprefixer")];
if (process.env.NODE_ENV === "production") {
plugins.push(
purgecss({
content: [
"./layouts/**/*.vue",
"./components/**/*.vue",
"./pages/**/*.vue"
],
whitelist: ["html", "body"],
whitelistPatternsChildren: [/^token/, /^pre/, /^code/],
extractors: [
{
extractor: TailwindExtractor,
extensions: ["html", "vue"]
}
]
})
);
}
module.exports = {
plugins
};
See https://vuedose.tips/tips/remove-unused-css-with-purge-css/ for more information, or google "purgecss with prism.js"
from gridsome-plugin-remark-prismjs-all.
I don't have a postcss file, what I have is a purge.config.js file. here is my repo
from gridsome-plugin-remark-prismjs-all.
Also, I would need help on the tags/classes to whitelist
from gridsome-plugin-remark-prismjs-all.
In this your repo, you seems to comment out the line that activates purge css in production.
from gridsome-plugin-remark-prismjs-all.
Works fine, I think this is the best solution. Thanks for all your help
from gridsome-plugin-remark-prismjs-all.
Related Issues (9)
- Demo page not working HOT 7
- remark attempts to read string interpolation inside code blocks
- Version 0.4.5 Build Error
- Heads-up that something recent in prism breaks nested code blocks HOT 1
- Seemingly unable to use with remark-code-import HOT 1
- How to configure other prismjs plugins
- [Bug] Font size not consistent across different languages HOT 1
- Unable to style inline blocks separately
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gridsome-plugin-remark-prismjs-all.