Skip to content

Commit

Permalink
feat(rollup): Add rollup plugin for loading CCM
Browse files Browse the repository at this point in the history
  • Loading branch information
joeljeske committed Feb 9, 2022
1 parent 0ee7812 commit 25b5dc6
Show file tree
Hide file tree
Showing 15 changed files with 3,954 additions and 5,727 deletions.
3 changes: 2 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
examples
27 changes: 27 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,33 @@ module.exports = function override(config, env) {

## Rollup

To use CCM with rollup, you can modify your config with the following plugins.

```sh
yarn add @css-components/rollup @css-components/react rollup-plugin-postcss
```

```js
// rollup.config.js

import ccm from '@css-components/rollup';
import postcss from 'rollup-plugin-postcss';

export default {
// ...
plugins: [
// CCM Handles all the transform of the ccm.css files
ccm(),

// PostCSS plugin picks up the CSS and can be configured as normal
postcss({
extract: true,
exclude: '**/*.ccm.css',
}),
],
};
```

## ESBuild

## Vite
Expand Down
27 changes: 0 additions & 27 deletions examples/rollup-js/ccm-plugin.js

This file was deleted.

5,678 changes: 0 additions & 5,678 deletions examples/rollup-js/package-lock.json

This file was deleted.

11 changes: 5 additions & 6 deletions examples/rollup-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"version": "1.0.0",
"private": true,
"scripts": {
"preinstall": "bazel build --config ci //packages/rollup:npm //packages/react:npm",

"start": "run-s build serve",
"serve": "http-server public",
"build": "run-s build:*",
"build:clean": "del .ccm public/dist",
"build:ccm": "ccm",
"build:rollup": "rollup -c rollup.config.js"
"build": "rollup -c rollup.config.js"
},
"devDependencies": {
"@babel/core": "7.14.6",
Expand All @@ -27,8 +26,8 @@
"rollup-plugin-postcss": "3.1.8"
},
"dependencies": {
"@css-components/cli": "0.0.4",
"@css-components/react": "0.0.4",
"@css-components/react": "link:../../.bazel/bin/packages/react/npm",
"@css-components/rollup": "link:../../.bazel/bin/packages/rollup/npm",
"react": "17.0.2",
"react-dom": "17.0.2"
}
Expand Down
30 changes: 15 additions & 15 deletions examples/rollup-js/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import babel from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import postcss from "rollup-plugin-postcss";
import autoprefixer from "autoprefixer";
import cssnano from "cssnano";

import ccm from "./ccm-plugin";
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import postcss from 'rollup-plugin-postcss';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import ccm from '@css-components/rollup';

export default {
input: "./src/index.jsx",
input: './src/index.jsx',
output: {
dir: "./public/dist",
format: "esm",
dir: './public/dist',
format: 'esm',
},
plugins: [
ccm(),
commonjs(),
babel({ babelHelpers: "bundled" }),
nodeResolve({ extensions: [".js", ".jsx"] }),
babel({ babelHelpers: 'bundled' }),
nodeResolve({ extensions: ['.js', '.jsx'] }),
replace({
"process.env.NODE_ENV": JSON.stringify("production"),
'process.env.NODE_ENV': JSON.stringify('production'),
}),
postcss({
extract: true,
plugins: [autoprefixer, cssnano],
exclude: '**/*.ccm.css',
}),
],
};
Loading

0 comments on commit 25b5dc6

Please sign in to comment.