Skip to content

Commit f281996

Browse files
authored
Merge pull request #65 from editor-js/migrate/vite
Migrate to vite
2 parents 193f5f6 + d20cddb commit f281996

File tree

9 files changed

+225
-3631
lines changed

9 files changed

+225
-3631
lines changed

.github/workflows/npm-publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- uses: actions/setup-node@v1
1414
with:
15-
node-version: 12
15+
node-version: 19
1616
registry-url: https://registry.npmjs.org/
1717
- run: yarn
1818
- run: yarn build

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ src/
44
.jshintrc
55
.postcssrc
66
.stylelintrc
7-
webpack.config.js
7+
vite.config.js
88
yarn.lock

.postcssrc

-3
This file was deleted.

.stylelintrc

-132
This file was deleted.

README.md

+3-20
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,19 @@ Code Tool for the [Editor.js](https://ifmo.su/editor) allows to include code exa
88

99
## Installation
1010

11-
### Install via NPM
12-
1311
Get the package
1412

1513
```shell
16-
npm i --save-dev @editorjs/code
14+
yarn add @editorjs/code
1715
```
1816

1917
Include module at your application
2018

2119
```javascript
22-
const CodeTool = require('@editorjs/code');
20+
import CodeTool from '@editorjs/code';
2321
```
2422

25-
### Download to your project's source dir
26-
27-
1. Upload folder `dist` from repository
28-
2. Add `dist/bundle.js` file to your page.
29-
30-
### Load from CDN
31-
32-
You can load specific version of package from [jsDelivr CDN](https://www.jsdelivr.com/package/npm/@editorjs/code).
33-
34-
`https://cdn.jsdelivr.net/npm/@editorjs/[email protected]`
35-
36-
Require this script on a page with Editor.js.
37-
38-
```html
39-
<script src="..."></script>
40-
```
23+
Optionally, you can load this tool from CDN [JsDelivr CDN](https://cdn.jsdelivr.net/npm/@editorjs/code@latest)
4124

4225
## Usage
4326

package.json

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
{
22
"name": "@editorjs/code",
3-
"version": "2.8.0",
3+
"version": "2.9.0",
44
"keywords": [
55
"codex editor",
66
"code",
7-
"tool",
87
"editor.js",
98
"editorjs"
109
],
1110
"description": "Code Tool for Editor.js",
1211
"license": "MIT",
1312
"repository": "https://github.com/editor-js/code",
14-
"main": "./dist/bundle.js",
13+
"files": [
14+
"dist"
15+
],
16+
"main": "./dist/code.umd.js",
17+
"module": "./dist/code.mjs",
18+
"exports": {
19+
".": {
20+
"import": "./dist/code.mjs",
21+
"require": "./dist/code.umd.js"
22+
}
23+
},
1524
"scripts": {
16-
"build": "webpack --mode production",
17-
"build:dev": "webpack --mode development --watch"
25+
"dev": "vite",
26+
"build": "vite build"
1827
},
1928
"author": {
20-
"name": "CodeX",
29+
"name": "CodeX Team",
2130
"email": "[email protected]"
2231
},
2332
"devDependencies": {
24-
"@babel/core": "^7.3.4",
25-
"@babel/preset-env": "^7.3.4",
26-
"babel-loader": "^8.0.5",
27-
"css-loader": "^3.5.3",
28-
"style-loader": "^1.2.1",
29-
"webpack": "^4.29.5",
30-
"webpack-cli": "^3.2.3"
33+
"vite": "^4.5.0",
34+
"vite-plugin-css-injected-by-js": "^3.3.0"
3135
},
3236
"dependencies": {
3337
"@codexteam/icons": "^0.0.5"

vite.config.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import path from "path";
2+
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
3+
import * as pkg from "./package.json";
4+
5+
const NODE_ENV = process.argv.mode || "development";
6+
const VERSION = pkg.version;
7+
8+
export default {
9+
build: {
10+
copyPublicDir: false,
11+
lib: {
12+
entry: path.resolve(__dirname, "src", "index.js"),
13+
name: "CodeTool",
14+
fileName: "code",
15+
},
16+
},
17+
define: {
18+
NODE_ENV: JSON.stringify(NODE_ENV),
19+
VERSION: JSON.stringify(VERSION),
20+
},
21+
22+
plugins: [cssInjectedByJsPlugin()],
23+
};

webpack.config.js

-34
This file was deleted.

0 commit comments

Comments
 (0)