Browse Source

Create a production build of Tailwind at release time (#292)

* Add support for purging tailwind styles. For #224

* Build prod version of tailwind in build script
pull/297/head
Gabe Kangas 5 years ago committed by GitHub
parent
commit
6d0aa4bdd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2004
      build/javascript/package-lock.json
  2. 5
      build/javascript/package.json
  3. 7
      build/javascript/postcss.config.js
  4. 6
      build/javascript/tailwind.config.js
  5. 11
      scripts/build.sh

2004
build/javascript/package-lock.json generated

File diff suppressed because it is too large Load Diff

5
build/javascript/package.json

@ -13,7 +13,10 @@ @@ -13,7 +13,10 @@
"video.js": "7.8.3",
"@videojs/http-streaming": "2.2.0"
},
"devDependencies": {},
"devDependencies": {
"cssnano": "^4.1.10",
"postcss-cli": "^8.1.0"
},
"snowpack": {
"install": [
"video.js/core.js",

7
build/javascript/postcss.config.js

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
module.exports = {
plugins: [
require('cssnano')({
preset: 'default',
}),
],
};

6
build/javascript/tailwind.config.js

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
module.exports = {
purge: {
mode: 'layers',
content: ['../../webroot/js/**.js', '../../webroot/js/**.html'],
},
};

11
scripts/build.sh

@ -27,6 +27,15 @@ rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.jpg @@ -27,6 +27,15 @@ rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.jpg
echo "Creating version ${VERSION} from commit ${GIT_COMMIT}"
# Create production build of Tailwind CSS
pushd build/javascript >> /dev/null
# Install the tailwind & postcss CLIs
npm install --quiet --no-progress
# Run the tailwind CLI and pipe it to postcss for minification.
# Save it to a temp directory that we will reference below.
NODE_ENV="production" ./node_modules/.bin/tailwind build | ./node_modules/.bin/postcss > "${TMPDIR}tailwind.min.css"
popd
mkdir -p dist
build() {
@ -46,6 +55,8 @@ build() { @@ -46,6 +55,8 @@ build() {
cp data/content-example.md dist/${NAME}/webroot/static/content.md
cp -R webroot/ dist/${NAME}/webroot/
# Copy the production pruned+minified css to the build's directory.
cp "${TMPDIR}tailwind.min.css" ./dist/${NAME}/webroot/js/web_modules/tailwindcss/dist/tailwind.min.css
cp -R doc/ dist/${NAME}/doc/
cp -R static/ dist/${NAME}/static
cp README.md dist/${NAME}

Loading…
Cancel
Save