Skip to content

Commit

Permalink
chore: add example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 20, 2022
1 parent d2d5122 commit 3c773c4
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 96 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/ci.yml
Expand Up @@ -6,12 +6,12 @@ on:

jobs:
build-deploy:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- run: mkdir -p build
- run: npm i markdown-to-html-cli -g
Expand All @@ -27,14 +27,14 @@ jobs:

- name: Is a tag created auto?
id: create_tag
uses: jaywcjlove/create-tag-action@v1.2.1
uses: jaywcjlove/create-tag-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
package-path: ./package.json

- name: Generate Changelog
id: changelog
uses: jaywcjlove/changelog-generator@v1.4.6
uses: jaywcjlove/changelog-generator@main
if: steps.create_tag.outputs.successful
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -56,5 +56,11 @@ jobs:
${{ steps.changelog.outputs.changelog }}
- run: npm install @jsdevtools/npm-publish -g
- run: npm-publish --token="${{ secrets.NPM_TOKEN }}" ./package.json
# - run: npm install @jsdevtools/npm-publish -g
# - run: npm-publish --token="${{ secrets.NPM_TOKEN }}" ./package.json

- name: 📦 next-remove-imports publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./core/package.json
24 changes: 24 additions & 0 deletions .gitignore
@@ -0,0 +1,24 @@
build
dist
node_modules
package-lock.json

.DS_Store
.cache
.vscode
.idea
.snap
.env
.next

*.bak
*.tem
*.temp
#.swp
*.*~
~*.*

# IDEA
*.iml
*.ipr
*.iws
68 changes: 0 additions & 68 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
68 changes: 68 additions & 0 deletions core/README.md
@@ -0,0 +1,68 @@
next-remove-imports
===

[![NPM Downloads](https://img.shields.io/npm/dm/next-remove-imports.svg?style=flat)](https://www.npmjs.com/package/next-remove-imports) [![Build & Deploy](https://github.com/uiwjs/next-remove-imports/actions/workflows/ci.yml/badge.svg)](https://github.com/uiwjs/next-remove-imports/actions/workflows/ci.yml)
[![Repo Dependents](https://badgen.net/github/dependents-repo/uiwjs/next-remove-imports)](https://github.com/uiwjs/next-remove-imports/network/dependents)

This is a plugin for [nextjs](https://github.com/vercel/next.js). The default behavior is to remove all `.less`/`.css`/`.scss`/`.sass`/`.styl` imports from all packages in node_modules.

> ⚠️ [CSS Imported by a Dependency](https://github.com/vercel/next.js/blob/master/errors/css-npm.md) [`#52`](https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341)
> - https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341
> - https://github.com/vercel/next.js/issues/9607
## Install

```shell
npm install next-remove-imports
# or
yarn add next-remove-imports
```

## Usage

```js
// next.config.js
const removeImports = require('next-remove-imports')({
options: { },
})
module.exports = removeImports()
```

```js
// next.config.js
const removeImports = require('next-remove-imports')()
module.exports = removeImports({
webpack(config, options) {
return config
},
});
```

```js
// next.config.js
const removeImports = require('next-remove-imports')({
test: /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/,
matchImports: "\\.(less|css|scss|sass|styl)$"
});

module.exports = removeImports({
webpack(config, options) {
return config
},
});
```

```js
// next.config.js
const removeImports = require('next-remove-imports')();

module.exports = (phase, { defaultConfig }) => {
return removeImports({
...defaultConfig
});
};
```

## License

Licensed under the MIT License.
File renamed without changes.
27 changes: 27 additions & 0 deletions core/package.json
@@ -0,0 +1,27 @@
{
"name": "next-remove-imports",
"version": "1.0.7",
"description": "The default behavior is to remove all `.less`/`.css`/`.scss`/`.sass`/`.styl` imports from all packages in node_modules.",
"homepage": "https://uiwjs.github.io/next-remove-imports/",
"main": "index.js",
"author": "kenny wang <wowohoo@qq.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/uiwjs/next-remove-imports"
},
"files": [
"index.js"
],
"keywords": [
"nextjs",
"serverless",
"plugin",
"next"
],
"dependencies": {
"@babel/core": "^7.14.3",
"babel-loader": "^8.2.2",
"babel-plugin-transform-remove-imports": "^1.5.4"
}
}
12 changes: 12 additions & 0 deletions example/next.config.js
@@ -0,0 +1,12 @@
const removeImports = require('next-remove-imports')();

module.exports = removeImports({
// ✅ options...
webpack: function(config) {
config.module.rules.push({
test: /\.md$/,
use: 'raw-loader',
})
return config
},
});
25 changes: 25 additions & 0 deletions example/package.json
@@ -0,0 +1,25 @@
{
"name": "example",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "jaywcjlove",
"license": "MIT",
"dependencies": {
"@uiw/react-md-editor": "^3.19.1",
"@uiw/react-markdown-preview": "^4.1.3",
"@wcj/dark-mode": "^1.0.15",
"next": "^12.3.1",
"next-remove-imports": "1.0.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"raw-loader": "^4.0.2"
}
}

0 comments on commit 3c773c4

Please sign in to comment.