Skip to content

Commit

Permalink
Merge pull request #297 from ember-learn/internal-postcss
Browse files Browse the repository at this point in the history
manually run postcss and add it to vendor
  • Loading branch information
MelSumner authored Mar 3, 2020
2 parents 0ff8f26 + 497ff1a commit aeb9d77
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 88 deletions.
12 changes: 6 additions & 6 deletions addon/styles/helpers/index.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import 'unstyled.css';
@import 'embed.css';
@import 'flex.css';
@import 'margin.css';
@import 'padding.css';
@import 'rounded.css';
@import 'helpers/unstyled.css';
@import 'helpers/embed.css';
@import 'helpers/flex.css';
@import 'helpers/margin.css';
@import 'helpers/padding.css';
@import 'helpers/rounded.css';

.img-fluid {
width: 100%;
Expand Down
18 changes: 0 additions & 18 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

const CssImport = require('postcss-import')
const PresetEnv = require('postcss-preset-env');

module.exports = function(defaults) {
let app = new EmberAddon(defaults, {
fingerprint: {
Expand All @@ -18,21 +15,6 @@ module.exports = function(defaults) {
'tests/dummy/public'
]
},
postcssOptions: {
compile: {
enabled: true,
plugins: [
{ module: CssImport },
{
module: PresetEnv,
options: {
stage: 3,
features: { 'nesting-rules': true }
}
}
]
}
},
// required until https://github.com/ember-cli/ember-cli/issues/8448 is fixed
'ember-prism': {
components: [
Expand Down
52 changes: 36 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,16 @@ const path = require('path');
const CssImport = require('postcss-import');
const PresetEnv = require('postcss-preset-env');

const broccoliPostCSS = require('broccoli-postcss')
const mergeTrees = require('broccoli-merge-trees');
const funnel = require('broccoli-funnel');
const get = require('lodash.get');
const { join } = require('path');

module.exports = {
name: require('./package').name,

options: {
postcssOptions: {
compile: {
enabled: true,
plugins: [
{ module: CssImport },
{
module: PresetEnv,
options: {
stage: 3,
features: { 'nesting-rules': true }
}
}
]
}
},

svgJar: {
sourceDirs: [
'public/images/icons',
Expand All @@ -34,6 +24,36 @@ module.exports = {
},
},

treeForAddon() {
var tree = this._super(...arguments);

const addonWithoutStyles = funnel(tree, {
exclude: ['**/*.css'],
});

const addonStyles = funnel(tree, {
include: ['ember-styleguide.css']
});

// I don't know exactly why targets is private so I am using `get()` to make
// sure that it isn't missing
let overrideBrowserslist = get(this, 'app.project._targets.browsers');

let processedStyles = broccoliPostCSS(addonStyles, {
plugins: [
CssImport({
path: join(__dirname, 'addon', 'styles'),
}),
PresetEnv({
stage: 3,
features: { 'nesting-rules': true },
overrideBrowserslist,
})
]});

return mergeTrees([addonWithoutStyles, processedStyles]);
},

treeForPublic: function() {
return new Funnel(path.join(this.root, 'public'));
},
Expand Down
47 changes: 1 addition & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
"@ember/render-modifiers": "^1.0.0",
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^3.0.1",
"broccoli-postcss": "^5.0.0",
"ember-angle-bracket-invocation-polyfill": "^2.0.2",
"ember-cli-babel": "^7.7.3",
"ember-cli-htmlbars": "^3.0.1",
"ember-cli-postcss": "^4.2.0",
"ember-svg-jar": "^1.2.2",
"ember-truth-helpers": "^2.1.0",
"lodash.get": "^4.4.2",
"normalize.css": "^8.0.1",
"postcss-import": "^12.0.1",
"postcss-preset-env": "^6.6.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/styles/app.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import 'color-pallet';
@import 'color-pallet.css';

.self-executing-code-block {
margin-bottom: 2rem;
Expand Down

0 comments on commit aeb9d77

Please sign in to comment.