Merge pull request #650 from tailwindcss/preflight-plugin
Convert preflight to plugin
This commit is contained in:
commit
e6371fc76f
9 changed files with 16 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
@tailwind preflight;
|
||||
@tailwind base;
|
||||
|
||||
@tailwind components;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
],
|
||||
"scripts": {
|
||||
"prebabelify": "rimraf lib",
|
||||
"babelify": "babel src --out-dir lib",
|
||||
"babelify": "babel src --out-dir lib --copy-files",
|
||||
"prepare": "npm run babelify && babel-node src/build.js",
|
||||
"style": "eslint .",
|
||||
"test": "jest && eslint ."
|
||||
|
|
|
|||
1
plugins/preflight.js
Normal file
1
plugins/preflight.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('../lib/plugins/preflight').default
|
||||
|
|
@ -1 +1 @@
|
|||
@tailwind preflight;
|
||||
@tailwind base;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import preflight from './plugins/preflight'
|
||||
import lists from './plugins/lists'
|
||||
import appearance from './plugins/appearance'
|
||||
import backgroundAttachment from './plugins/backgroundAttachment'
|
||||
|
|
@ -68,6 +69,7 @@ function loadPlugins({ theme, variants, corePlugins }, plugins) {
|
|||
|
||||
export default function(config) {
|
||||
return loadPlugins(config, {
|
||||
preflight,
|
||||
lists,
|
||||
appearance,
|
||||
backgroundAttachment,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import fs from 'fs'
|
||||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
|
||||
|
|
@ -14,15 +13,6 @@ export default function(
|
|||
) {
|
||||
return function(css) {
|
||||
css.walkAtRules('tailwind', atRule => {
|
||||
if (atRule.params === 'preflight') {
|
||||
const preflightTree = postcss.parse(
|
||||
fs.readFileSync(`${__dirname}/../../css/preflight.css`, 'utf8')
|
||||
)
|
||||
|
||||
atRule.before(updateSource(preflightTree, atRule.source))
|
||||
atRule.remove()
|
||||
}
|
||||
|
||||
if (atRule.params === 'base') {
|
||||
atRule.before(updateSource(pluginBase, atRule.source))
|
||||
atRule.remove()
|
||||
|
|
|
|||
9
src/plugins/preflight.js
Normal file
9
src/plugins/preflight.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import fs from 'fs'
|
||||
import postcss from 'postcss'
|
||||
|
||||
export default function() {
|
||||
return function({ addBase }) {
|
||||
const preflightStyles = postcss.parse(fs.readFileSync(`${__dirname}/css/preflight.css`, 'utf8'))
|
||||
addBase(preflightStyles.nodes)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@tailwind preflight;
|
||||
@tailwind base;
|
||||
|
||||
@tailwind components;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue