Skip to content

Commit e6371fc

Browse files
authored
Merge pull request #650 from tailwindcss/preflight-plugin
Convert preflight to plugin
2 parents 76c40e4 + a9bab6e commit e6371fc

File tree

9 files changed

+16
-14
lines changed

9 files changed

+16
-14
lines changed

__tests__/fixtures/tailwind-input.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@tailwind preflight;
1+
@tailwind base;
22

33
@tailwind components;
44

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"scripts": {
2020
"prebabelify": "rimraf lib",
21-
"babelify": "babel src --out-dir lib",
21+
"babelify": "babel src --out-dir lib --copy-files",
2222
"prepare": "npm run babelify && babel-node src/build.js",
2323
"style": "eslint .",
2424
"test": "jest && eslint ."

plugins/preflight.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../lib/plugins/preflight').default

preflight.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@tailwind preflight;
1+
@tailwind base;

src/corePlugins.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import preflight from './plugins/preflight'
12
import lists from './plugins/lists'
23
import appearance from './plugins/appearance'
34
import backgroundAttachment from './plugins/backgroundAttachment'
@@ -68,6 +69,7 @@ function loadPlugins({ theme, variants, corePlugins }, plugins) {
6869

6970
export default function(config) {
7071
return loadPlugins(config, {
72+
preflight,
7173
lists,
7274
appearance,
7375
backgroundAttachment,

src/lib/substituteTailwindAtRules.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fs from 'fs'
21
import _ from 'lodash'
32
import postcss from 'postcss'
43

@@ -14,15 +13,6 @@ export default function(
1413
) {
1514
return function(css) {
1615
css.walkAtRules('tailwind', atRule => {
17-
if (atRule.params === 'preflight') {
18-
const preflightTree = postcss.parse(
19-
fs.readFileSync(`${__dirname}/../../css/preflight.css`, 'utf8')
20-
)
21-
22-
atRule.before(updateSource(preflightTree, atRule.source))
23-
atRule.remove()
24-
}
25-
2616
if (atRule.params === 'base') {
2717
atRule.before(updateSource(pluginBase, atRule.source))
2818
atRule.remove()
File renamed without changes.

src/plugins/preflight.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import fs from 'fs'
2+
import postcss from 'postcss'
3+
4+
export default function() {
5+
return function({ addBase }) {
6+
const preflightStyles = postcss.parse(fs.readFileSync(`${__dirname}/css/preflight.css`, 'utf8'))
7+
addBase(preflightStyles.nodes)
8+
}
9+
}

tailwind.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@tailwind preflight;
1+
@tailwind base;
22

33
@tailwind components;
44

0 commit comments

Comments
 (0)