8000 Generate minified file on build · nerdx128/tailwindcss@8e1fcd7 · GitHub
Skip to content

Commit 8e1fcd7

Browse files
committed
Generate minified file on build
Useful for checking gzip size and making sure we are still reasonable. Currently at 19.6kb 🤙🏻
1 parent e513a00 commit 8e1fcd7

4 files changed

Lines changed: 41 additions & 6 deletions

File tree

dist/tailwind.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"babel-preset-react": "^6.24.1",
3030
"babel-preset-stage-2": "^6.24.1",
3131
"babel-preset-stage-3": "^6.24.1",
32+
"clean-css": "^4.1.9",
3233
"jest": "^20.0.4",
3334
"rimraf": "^2.6.1"
3435
},
@@ -38,8 +39,8 @@
3839
"nodemon": "^1.11.0",
3940
"normalize.css": "^7.0.0",
4041
"postcss": "^6.0.9",
41-
"postcss-import": "^11.0.0",
4242
"postcss-functions": "^3.0.0",
43+
"postcss-import": "^11.0.0",
4344
"stylefmt": "^6.0.0"
4445
},
4546
"browserslist": [

src/build.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'fs'
22
import postcss from 'postcss'
33
import tailwind from '..'
44
import defaultConfig from './defaultConfig'
5+
import CleanCSS from 'clean-css'
56

67
console.info('Building Tailwind!')
78

@@ -10,11 +11,18 @@ fs.readFile('./css/tailwind.css', (err, css) => {
1011
.process(css, {
1112
from: './css/tailwind.css',
1213
to: './dist/tailwind.css',
13-
map: {inline: false},
14+
map: { inline: false },
1415
})
1516
.then(result => {
1617
fs.writeFileSync('./dist/tailwind.css', result.css)
17-
if (result.map) fs.writeFileSync('./dist/tailwind.css.map', result.map)
18+
if (result.map) {
19+
fs.writeFileSync('./dist/tailwind.css.map', result.map)
20+
}
21+
return result
22+
})
23+
.then(result => {
24+
const minified = new CleanCSS().minify(result.css)
25+
fs.writeFileSync('./dist/tailwind.min.css', minified.styles)
1826
})
1927
.catch(error => console.log(error))
2028
})

yarn.lock

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,12 @@ circular-json@^0.3.1:
10561056
version "0.3.3"
10571057
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66"
10581058

1059+
clean-css@^4.1.9, clean-css@^4.x:
1060+
version "4.1.9"
1061+
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.9.tgz#35cee8ae7687a49b98034f70de00c4edd3826301"
1062+
dependencies:
1063+
source-map "0.5.x"
1064+
10591065
cli-boxes@^1.0.0:
10601066
version "1.0.0"
10611067
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143"
@@ -3065,6 +3071,13 @@ plur@^2.0.0, plur@^2.1.2:
30653071
dependencies:
30663072
irregular-plurals "^1.0.0"
30673073

3074+
postcss-clean@^1.1.0:
3075+
version "1.1.0"
3076+
resolved "https://registry.yarnpkg.com/postcss-clean/-/postcss-clean-1.1.0.tgz#c2d61d5d8caf19a585adba16897726c2674c4207"
3077+
dependencies:
3078+
clean-css "^4.x"
3079+
postcss "^6.x"
3080+
30683081
postcss-functions@^3.0.0:
30693082
version "3.0.0"
30703083
resolved "https://registry.yarnpkg.com/postcss-functions/-/postcss-functions-3.0.0.tgz#0e94d01444700a481de20de4d55fb2640564250e"
@@ -3163,6 +3176,14 @@ postcss@^6.0.1, postcss@^6.0.3, postcss@^6.0.9:
31633176
source-map "^0.5.7"
31643177
supports-color "^4.4.0"
31653178

3179+
postcss@^6.x:
3180+
version "6.0.13"
3181+
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.13.tgz#b9ecab4ee00c89db3ec931145bd9590bbf3f125f"
3182+
dependencies:
3183+
chalk "^2.1.0"
3184+
source-map "^0.6.1"
3185+
supports-color "^4.4.0"
3186+
31663187
prelude-ls@~1.1.2:
31673188
version "1.1.2"
31683189
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
@@ -3527,15 +3548,19 @@ source-map-support@^0.4.15:
35273548
dependencies:
35283549
source-map "^0.5.6"
35293550

3551+
source-map@0.5.x, source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1, source-map@~0.5.6:
3552+
version "0.5.7"
3553+
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
3554+
35303555
source-map@^0.4.2, source-map@^0.4.4:
35313556
version "0.4.4"
35323557
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
35333558
dependencies:
35343559
amdefine ">=0.0.4"
35353560

3536-
source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1, source-map@~0.5.6:
3537-
version "0.5.7"
3538-
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
3561+
source-map@^0.6.1:
3562+
version "0.6.1"
3563+
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
35393564

35403565
spdx-correct@~1.0.0:
35413566
version "1.0.2"

0 commit comments

Comments
 (0)