Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently export stylesheet #456

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
on: [pull_request]

jobs:
build:
Expand All @@ -13,24 +13,27 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js LTS
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
# alias support: https://github.com/actions/setup-node/issues/26
node-version: '12'
node-version: '20'
- uses: pnpm/action-setup@v2
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache NPM dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-npm-cache-${{ matrix.os }}
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.OS }}-npm-cache-${{ matrix.os }}
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: |
npm install -g yarn
yarn --frozen-lockfile --non-interactive
run:
pnpm install --frozen-lockfile
- name: Test
run: yarn test
run: pnpm test
- name: Lint
run: yarn lint
run: pnpm lint
env:
CI: true
30 changes: 17 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
name: Release

on: [push]
on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js LTS
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
# alias support: https://github.com/actions/setup-node/issues/26
node-version: '14'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
node-version: '20'
- uses: pnpm/action-setup@v2
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-store-
- name: Install Dependencies
run: yarn
run: pnpm install --frozen-lockfile
- name: Semantic Release
run: npx semantic-release
env:
Expand Down
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"xo.enable": true,
"xo.format.enable": true,
"[javascript]": {
"editor.defaultFormatter": "samverschueren.linter-xo"
},
"[javascriptreact]": {
"editor.defaultFormatter": "samverschueren.linter-xo"
},
"[typescript]": {
"editor.defaultFormatter": "samverschueren.linter-xo"
},
"[typescriptreact]": {
"editor.defaultFormatter": "samverschueren.linter-xo"
}
}
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# rollup-plugin-postcss

[![NPM version](https://img.shields.io/npm/v/rollup-plugin-postcss.svg?style=flat)](https://npmjs.com/package/rollup-plugin-postcss) [![NPM downloads](https://img.shields.io/npm/dm/rollup-plugin-postcss.svg?style=flat)](https://npmjs.com/package/rollup-plugin-postcss) [![Build Status](https://img.shields.io/circleci/project/egoist/rollup-plugin-postcss/master.svg?style=flat)](https://circleci.com/gh/egoist/rollup-plugin-postcss) [![codecov](https://codecov.io/gh/egoist/rollup-plugin-postcss/branch/master/graph/badge.svg)](https://codecov.io/gh/egoist/rollup-plugin-postcss)
[![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/egoist/donate)
[![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/egoist/donate)

<img align="right" width="95" height="95"
title="Philosopher’s stone, logo of PostCSS"
Expand All @@ -12,15 +12,15 @@ Seamless integration between [Rollup](https://github.com/rollup/rollup) and [Pos
## Install

```bash
yarn add postcss rollup-plugin-postcss --dev
pnpm add postcss rollup-plugin-postcss --dev
```

## Usage

`v2.0` support rollup v1 or above, but it prints deprecated warning from rollup v2.

**Breaking change**: `v3.0` only support rollup v2, and the extract path based on bundle root
the location of the generated file outside the bundle directory not allowed in rollup v2.
the location of the generated file outside the bundle directory not allowed in rollup v2.

```js
// rollup.config.js
Expand All @@ -41,13 +41,20 @@ Then you can use CSS files:
import './style.css'
```

Note that the generated CSS will be injected to `<head>` by default, and the CSS string is also available as default export unless `extract: true`:
Note that the generated CSS will be injected to `<head>` by default., and the CSS string is also available as default export unless `extract: true` or `modules` is enabled:

```js
// Inject to `<head>` and also available as `style`
import style from './style.css'
```

In all cases the styles can be accessed directly as a named export. So if css modules are enabled, then:

```js
// Default export is classnames, named `stylesheet` is the CSS string
import classNames, { stylesheet } from './style.css'
```

It will also automatically use local PostCSS config files.

### Extract CSS
Expand Down Expand Up @@ -83,15 +90,15 @@ postcss({

Install corresponding dependency:

- For `Sass` install `node-sass`: `yarn add node-sass --dev`
- For `Stylus` Install `stylus`: `yarn add stylus --dev`
- For `Less` Install `less`: `yarn add less --dev`
- For `Sass` install `node-sass`: `pnpm add node-sass --dev`
- For `Stylus` Install `stylus`: `pnpm add stylus --dev`
- For `Less` Install `less`: `pnpm add less --dev`

That's it, you can now import `.styl` `.scss` `.sass` `.less` files in your library.

#### imports

__For Sass/Scss Only.__
**For Sass/Scss Only.**

Similar to how webpack's [sass-loader](https://github.com/webpack-contrib/sass-loader#imports) works, you can prepend the path with `~` to tell this plugin to resolve in `node_modules`:

Expand Down Expand Up @@ -266,7 +273,7 @@ module.exports = context => {

Type: `string`

Destination CSS filename hint that could be used by PostCSS plugins, for example,
Destination CSS filename hint that could be used by PostCSS plugins, for example,
to properly resolve path, rebase and copy assets.

### use
Expand Down
31 changes: 0 additions & 31 deletions circle.yml

This file was deleted.

68 changes: 45 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,69 @@
{
"name": "rollup-plugin-postcss",
"version": "3.0.0",
"name": "@dougalg/rollup-plugin-postcss",
"version": "4.0.0",
"description": "Seamless integration between Rollup and PostCSS",
"main": "dist/index.js",
"packageManager": "[email protected]",
"files": [
"dist",
"types/index.d.ts"
],
"scripts": {
"test": "npm run lint && jest",
"test:cov": "npm run lint && jest --coverage",
"test": "pnpm run lint && jest",
"test:cov": "pnpm run lint && jest --coverage",
"build": "bili",
"lint": "xo",
"prepublishOnly": "npm run build"
"prepublishOnly": "pnpm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/egoist/rollup-plugin-postcss.git"
"url": "git+https://github.com/dougalg/rollup-plugin-postcss.git"
},
"keywords": [
"postcss",
"rollup"
],
"author": "EGOIST <[email protected]>",
"contributors": [
"Dougal Graham <[email protected]>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/egoist/rollup-plugin-postcss/issues"
"url": "https://github.com/dougalg/rollup-plugin-postcss/issues"
},
"engines": {
"node": ">=10"
"node": ">=12.5.0"
},
"types": "./types/index.d.ts",
"homepage": "https://github.com/egoist/rollup-plugin-postcss#readme",
"homepage": "https://github.com/dougalg/rollup-plugin-postcss#readme",
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"autoprefixer": "^10.0.4",
"@babel/core": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"autoprefixer": "^10.4.16",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.6.3",
"babel-jest": "^29.7.0",
"bili": "^5.0.5",
"eslint-config-rem": "^4.0.0",
"fs-extra": "^9.0.1",
"jest": "^26.6.3",
"jest": "^29.7.0",
"less": "^3.12.2",
"node-sass": "^5.0.0",
"postcss": "^8.2.7",
"rollup": "^2.34.2",
"node-sass": "^9.0.0",
"postcss": "^8.4.32",
"rollup": "^4.9.1",
"stylus": "^0.54.8",
"sugarss": "^3.0.3",
"xo": "^0.35.0"
"xo": "^0.56.0"
},
"dependencies": {
"chalk": "^4.1.0",
"concat-with-sourcemaps": "^1.1.0",
"cssnano": "^5.0.1",
"cssnano": "^6.0.2",
"import-cwd": "^3.0.0",
"p-queue": "^6.6.2",
"pify": "^5.0.0",
"postcss-load-config": "^3.0.0",
"postcss-modules": "^4.0.0",
"promise.series": "^0.2.0",
"resolve": "^1.19.0",
"resolve": "^1.22.8",
"rollup-pluginutils": "^2.8.2",
"safe-identifier": "^0.4.2",
"style-inject": "^0.3.0"
Expand All @@ -74,16 +77,32 @@
"jest"
],
"rules": {
"unicorn/prefer-spread": 0,
"@typescript-eslint/naming-convention": 0,
"n/prefer-global/process": 0,
"n/prefer-global/buffer": 0,
"unicorn/prefer-module": 0,
"import/prefer-default-export": 0,
"import/extensions": 0,
"import/no-unassigned-import": 0,
"@typescript-eslint/semi": 0,
"eslint-comments/disable-enable-pair": 0,
"promise/prefer-await-to-then": 0
}
},
"overrides": [
{
"files": ["**/*.ts"],
"rules": {
"object-curly-spacing": 0
}
}
]
},
"jest": {
"testEnvironment": "node"
"testEnvironment": "node",
"transformIgnorePatterns": [
"/node_modules/(?!(rollup)/)"
]
},
"babel": {
"presets": [
Expand All @@ -102,5 +121,8 @@
"master",
"next"
]
},
"publishConfig": {
"access": "public"
}
}
Loading