Created
April 12, 2020 00:34
-
-
Save josemarluedke/0b76a1f641041241f7065ab9fe4f05af to your computer and use it in GitHub Desktop.
Ember + TailwindCSS + PurgeCSS + CSS Modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const EmberApp = require('ember-cli/lib/broccoli/ember-app'); | |
const env = EmberApp.env(); | |
const purgecssOptions = { | |
content: ['./app/index.html', './app/**/*.hbs', './node_modules/**/*.hbs'], | |
defaultExtractor: (content) => { | |
return content.match(/[A-Za-z0-9-_:/]+/g) || []; | |
}, | |
// Leave css definitions starting with an underscore untouched. | |
// This prevents css definitions generated by ember-css-modules | |
// from being purged. | |
whitelistPatterns: [/^_/, /js-/] | |
}; | |
const cssModulesPlugins = [ | |
require('postcss-import')({ path: ['node_modules'] }), | |
require('postcss-css-variables')({ preserve: true }), | |
require('tailwindcss')('./app/styles/tailwind.config.js'), | |
require('autoprefixer')({ | |
overrideBrowserslist: require('./config/targets').browsers | |
}) | |
]; | |
if (env !== 'development' || process.env.PURGE_CSS === 'true') { | |
const purgecss = require('@fullhuman/postcss-purgecss')(purgecssOptions); | |
cssModulesPlugins.push(purgecss); | |
} | |
module.exports = function (defaults) { | |
const app = new EmberApp(defaults, { | |
cssModules: { | |
plugins: cssModulesPlugins | |
} | |
}); | |
return app.toTree(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment