Skip to content

Example for utilizing ES6 Modules #14

@maurer2

Description

@maurer2

Hello, I think an example of how to use the plugin with es6 modules could be helpful. Here's an proposal:

Use (ES6)

import postcss from 'postcss';
import spiffing from 'postcss-spiffing';
import * as fs from 'fs';

const css = fs.readFileSync('random.css');

console.log(postcss(spiffing()).process(css).css);

Maybe a section about loading ES6 modules in node with ESM (https://github.com/standard-things/esm) might be helpful, too:

Execute in Node >= 13

// Execute directly
node main.js

// Execute via npm scripts
// package.json
{
  ...
  "type": "module",
  "scripts": {
    "convert": "node main.js"
  }
  ....
}
// Command line
npm run convert
yarn convert

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions