Skip to content

browserify #3

Closed
Closed

Description

@knownasilya

Is this possible with browserify? Would love an example if it is.

Activity

  1. sokra commented on May 27, 2015

    @sokra
    Member

    Currently not. Currently CSS Modules are only possible with webpack.

    But @joshgillies want to write a browserify transform once we get the stuff ready: webpack/css-loader#60 (comment)

  2. knownasilya commented on May 27, 2015

    @knownasilya
    Author

    Sweet! I'll see how that works!

  3. geelen commented on May 27, 2015

    @geelen
    Member

    I'm currently writing the JSPM loader implementation, and Browserify shouldn't be too difficult for someone who understands the internals. Basically, all the syntax transformations are being done by the three PostCSS plugins: postcss-modules-local-by-default,postcss-modules-extract-importsandpostcss-modules-scope. But then the file contains:importand:export` primitives, which aren't documented outside of webpack/css-loader#60. That's what needs to be specialised between Webpack/JSPM/Browserify, and then the whole package needs to be bundled up into an easy-to-install project.

    Btw, by dropping postcss-modules-local-by-default off the chain, you get opt-in CSS Modules behaviour, since the other two plugins look for :local directives before they do anything. But when both Webpack & JSPM have loaders, it'll be easier to follow.

  4. serapath commented on May 29, 2015

    @serapath

    I'm not sure if that solves the same problem, but are you aware of atomify?

    You can create a project called mybuttoncss that contains just:

    • index.css
    • package.json

    and publish it to npm. Then, in another project buttontest you do: npm install mybuttoncss and in that projects buttontest/index.css you write:

    @import 'mybuttoncss'
    /* ... */

    Advanced

    If you want to pass variables around, you can just define in mybuttoncss project:

    /*[mybuttoncss/index.css]*/
    :root {
      --mybuttoncss1: #ff0000;
      --mybuttoncss2: 50px;
      /* .... */
    }
    body {
      background-color: var(--mybuttoncss1);
      font-size: var(--mybuttoncss2);
    }

    and then in buttontest

    /*[buttontestProject/index.css]*/
    @import 'mybuttoncss'
    root: {
      --mybuttoncss1: green;
      --mybuttoncss2: 15px;
      /* .... */
    }

    If you in general stick to BEM conventions in all your modules, it works quite fine and the project can in general be extended with a lot of rework plugins and in the the future postcss is planned. There is already support for autoprefixer :-)

    If you want to learn a bit more - even though it currently lacks some "user friendlyness", you could follow this tutorial atomify slides

    If you do, i recommend you to spend some time with each slide not just copy & pasting commands, but thinking about them and analyzing what was created in your directories and text editor.
    In the slides, 2 components get created, were one is using the other. Additionally, at the end, the themeing which i described above is demonstrated.

  5. added a commit that references this issue on May 7, 2019
    a491a91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions