Meteor-Community-Packages / meteor-postcss

PostCSS for Meteor

Home Page:https://packosphere.com/juliancwirko/postcss

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using inside a package?

SachaG opened this issue · comments

Can this package be used to process CSS/SCSS files inside another package? If so, how would you specify its options?

Hi, do you want to use config json file inside a package? For now it isn't possible and I wonder how to provide it, because for now all configuration lands in a standard package.json file (from Meteor 1.3). For packages there should be another config file which should be merged with all other config files from packages and package.json file too (while building). This PostCSS solution in Meteor is quite hacky :/ Even with .json config files we can't configure everything because some PostCSS plugins takes functions as options. The second thing are imports. PostCSS can use a plugin for imports, I don't think it works with packages too. I mean you can't import from package. (this is probably simpler to achive than config files in packages).

There are many questions for now, like if Meteor packages will live long or will there be something better for tools like PostCSS soon in the Meteor's build system. Even now you can use Webpack with Meteor, with this stack using PostCSS and preprocessors is much much simpler. Another question is how we will structure our apps and components, do we even need css imports when we can use CSS Modules?

For now I don't know exactly which path such packages should take, but I'll try to think about separated config files in packages and imports from packages.

If you have any ideas please let me know :)

Haha, so many questions! I'm all for using Webpack and all that, but I don't think it works with Meteor packages. Which is a problem for me since Telescope uses a package-based architecture… So for now I guess I'll keep looking. I'm really just looking for a way to run Autoprefixer on SCSS files contained inside packages, maybe there's a simpler workaround?

Ok, so you want to have autoprefixer without instructions for the user how to enable it, right? There is also https://atmospherejs.com/seba/minifiers-autoprefixer but I think it works the same way. You can try this one if you need only Autoprefixer and I'll try to do some research too. There are many cool plugins for PostCSS like https://github.com/postcss/postcss-scss . I think with proper PostCSS support we will be able to use Scss even without fourseven:scss package.

If you have something like (Meteor 1.3):

in the package package.js:

Package.onUse(function(api) {
  (...)
  api.use('fourseven:scss', 'client');
  api.addFiles('test.scss', 'client');
  (...)
});

and in your app in package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "author": "",
  "devDependencies": {
    "autoprefixer": "^6.3.3"
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {
        "browsers": [
          "last 2 versions"
        ]
      }
    }
  }
}

It will work as it should. Autoprefixer will work, but I gues you don't want to use package.json for now. I think with Meteor 1.3 you need to do this anyway ;)