Skip to content

Syntax #124

Open
Open

Description

@alexisvincent

How would we use syntax plugins, like https://github.com/postcss/postcss-scss?

Activity

  1. joshwnj commented on May 30, 2016

    @joshwnj
    Member

    @alexisvincent are you using something like webpack or browserify? There are some examples of using CSS Modules alongside other postcss plugins:

  2. alexisvincent commented on May 30, 2016

    @alexisvincent
    Author

    @joshwnj Nope, trying to use this project to fix up the JSPM loader.

  3. joshwnj commented on May 31, 2016

    @joshwnj
    Member

    @alexisvincent ah ok. Have you seen the jspm demo?

    I'm not very familiar with JSPM myself but if I were looking I would start by trying to add the postcss-scss plugin to the beginning of the plugin array here: https://github.com/geelen/jspm-loader-css-modules/blob/master/index.js#L3-L9

  4. alexisvincent commented on May 31, 2016

    @alexisvincent
    Author

    Yep, the issue is that scss isn't a plugin, it's a syntax, so the postcss semantics are different, the syntax gets passed in as part of the process options. However in this project we can't change the options. To resolve this I've forked and manually added the ability to pass options. Was hoping to get the conversation started around extending this project to deal with options as well.

  5. jessicamindel commented on Jan 15, 2019

    @jessicamindel

    @alexisvincent Excited to hear that you found a workaround! I'm not using JSPM myself, but am curious as to how you were able to pass in your processOptions. I was looking to use SCSS with TypeScript in Webpack while getting around a current issue with typings-for-css-modules-loader using this article, but haven't been able to pass in syntax option.

  6. alexisvincent commented on Jan 16, 2019

    @alexisvincent
    Author

    @jessicamindel Oh boy! This was soo long ago I can barely remember anything about it. Issues around JSPM and SystemJS were largely that all this loading had to happen in the browser, rather than serverside. I'm sorry, but I'm going to be of absolutely no use. Good luck though!

  7. alexisvincent commented on Jan 16, 2019

    @alexisvincent
    Author

    I don't think this project has kept up to date though, so you might have more luck elsewhere.

  8. nathanredblur commented on Oct 3, 2019

    @nathanredblur

    I think you can add some param to support scss syntax like:

    .process( sourceString, { from: "/" + sourcePath } )

    var postcssScss = require("postcss-scss");
    
    export default class Core {
      constructor( plugins, syntax ) {
        this.plugins = plugins || Core.defaultPlugins
        this.syntax = syntax || postcssScss
      }
    
      load( sourceString, sourcePath, trace, pathFetcher ) {
        let parser = new Parser( pathFetcher, trace )
    
        return postcss( this.plugins.concat( [parser.plugin] ) )
          .process( sourceString, { syntax: this.syntax, from: "/" + sourcePath } )
          .then( result => {
            return { injectableSource: result.css, exportTokens: parser.exportTokens }
          } )
      }
    }
    
    

    tell me what is the best approach for this. the scss processor works well with css, and in case that some scss appear, we can parse it with the same syntax processor also we can allow send some custom syntax.
    Or even better and forget all about send plugins or syntax and try to support the use of postcss.config.js file.

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