Skip to content

Commit f513251

Browse files
authored
Merge pull request #80 from bettysteger/master
fix production build and migrate from webpack to vite Thanks, @bettysteger
2 parents 47c1fac + 25be3f5 commit f513251

File tree

13 files changed

+613
-5081
lines changed

13 files changed

+613
-5081
lines changed

.github/workflows/lint-and-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
name: Production build
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
- name: Cache node modules
1212
id: cache-node-modules
13-
uses: actions/cache@v3
13+
uses: actions/cache@v4
1414
env:
1515
cache-name: node-modules-cache
1616
with:

.github/workflows/npm-publish.yml

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,8 @@ on:
66
- master
77

88
jobs:
9-
publish:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-node@v1
14-
with:
15-
node-version: 12
16-
registry-url: https://registry.npmjs.org/
17-
- run: yarn
18-
- run: yarn build
19-
- run: yarn publish --access=public
20-
env:
21-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22-
notify:
23-
needs: publish
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v2
27-
- name: Get package info
28-
id: package
29-
uses: codex-team/action-nodejs-package-info@v1
30-
- name: Send a message
31-
uses: codex-team/action-codexbot-notify@v1
32-
with:
33-
webhook: ${{ secrets.CODEX_BOT_NOTIFY_EDITORJS_PUBLIC_CHAT }}
34-
message: '📦 [${{ steps.package.outputs.name }}](${{ steps.package.outputs.npmjs-link }}) ${{ steps.package.outputs.version }} was published'
35-
parse_mode: 'markdown'
36-
disable_web_page_preview: true
9+
publish-and-notify:
10+
uses: codex-team/github-workflows/.github/workflows/npm-publish-and-notify-reusable.yml@main
11+
secrets:
12+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
13+
CODEX_BOT_NOTIFY_EDITORJS_PUBLIC_CHAT: ${{ secrets.CODEX_BOT_NOTIFY_EDITORJS_PUBLIC_CHAT }}

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.idea/
22
src/
33
.eslintrc
4-
webpack.config.js
4+
vite.config.js
55
yarn.lock

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.18.1

dev/index.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Attaches Plugin Test | EditorJS</title>
7+
</head>
8+
<body>
9+
<div id="editorjs"></div>
10+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
11+
<script type="module">
12+
import AttachesTool from "../src/index.js";
13+
const editor = new EditorJS({
14+
holder: "editorjs",
15+
data: {
16+
time: 1700475383740,
17+
blocks: [],
18+
},
19+
20+
tools: {
21+
image: {
22+
class: AttachesTool,
23+
config: {
24+
endpoint: "http://localhost:8008/uploadFile"
25+
},
26+
},
27+
},
28+
});
29+
</script>
30+
</body>
31+
</html>

dev/server.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const http = require('http');
1313
const formidable = require('formidable');
1414
const crypto = require('crypto');
1515

16+
const SERVER_PORT = 8008;
17+
1618
/**
1719
* Sample server for files upload
1820
*/
@@ -80,13 +82,13 @@ class ServerExample {
8082

8183
this.getForm(request)
8284
.then(({ files }) => {
83-
let file = files[this.fieldName] || {};
85+
let file = files[this.fieldName][0] || {};
8486

8587
responseJson.success = 1;
8688
responseJson.file = {
87-
url: file.path,
88-
name: file.name,
89-
size: file.size,
89+
url: `http://localhost:${SERVER_PORT}/file/` + file.newFilename,
90+
name: file.originalFilename,
91+
size: file.size
9092
};
9193
})
9294
.catch((error) => {
@@ -132,8 +134,7 @@ class ServerExample {
132134
}
133135
}
134136

135-
136137
new ServerExample({
137-
port: 8008,
138+
port: SERVER_PORT,
138139
fieldName: 'file'
139-
});
140+
});

package.json

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
11
{
22
"name": "@editorjs/attaches",
3-
"version": "1.3.1",
4-
"repository": "https://github.com/editor-js/attaches",
5-
"license": "MIT",
6-
"scripts": {
7-
"build": "webpack --mode production",
8-
"build:dev": "webpack --mode development --watch",
9-
"server": "node ./dev/server.js"
10-
},
3+
"version": "1.3.2",
114
"keywords": [
125
"codex editor",
13-
"tool",
146
"attaches",
157
"editor.js",
168
"editorjs"
179
],
10+
"description": "Attaches Tool for Editor.js",
11+
"license": "MIT",
12+
"repository": "https://github.com/editor-js/attaches",
13+
"files": [
14+
"dist"
15+
],
16+
"main": "./dist/attaches.umd.js",
17+
"module": "./dist/attaches.mjs",
18+
"exports": {
19+
".": {
20+
"import": "./dist/attaches.mjs",
21+
"require": "./dist/attaches.umd.js"
22+
}
23+
},
24+
"scripts": {
25+
"dev": "concurrently \"vite\" \"node ./dev/server.js\"",
26+
"build": "vite build"
27+
},
1828
"author": {
1929
"name": "CodeX",
2030
"email": "[email protected]"
2131
},
22-
"main": "./dist/bundle.js",
2332
"devDependencies": {
24-
"@babel/core": "^7.14.2",
25-
"@babel/preset-env": "^7.14.2",
26-
"@codexteam/ajax": "^4.0.1",
27-
"babel-loader": "^8.2.2",
28-
"css-loader": "^1.0.0",
29-
"eslint": "^7.32.0",
30-
"eslint-config-codex": "^1.6.4",
31-
"eslint-webpack-plugin": "^3.2.0",
32-
"file-loader": "^4.1.0",
33-
"formidable": "^1.2.1",
34-
"postcss-loader": "^3.0.0",
35-
"postcss-nested": "^4.1.1",
36-
"postcss-nested-ancestors": "^2.0.0",
37-
"request": "^2.88.0",
38-
"style-loader": "^0.21.0",
39-
"svg-inline-loader": "^0.8.2",
40-
"to-string-loader": "^1.2.0",
41-
"webpack": "^4.29.6",
42-
"webpack-cli": "^3.3.0"
33+
"@editorjs/editorjs": "2.30.0-rc.12",
34+
"concurrently": "^9.0.1",
35+
"formidable": "^3.5.1",
36+
"postcss-nested": "^7.0.2",
37+
"postcss-nested-ancestors": "^3.0.0",
38+
"vite": "^5.3.1",
39+
"vite-plugin-css-injected-by-js": "^3.5.1"
4340
},
4441
"dependencies": {
45-
"@codexteam/icons": "^0.0.4"
42+
"@codexteam/ajax": "^4.2.0",
43+
"@codexteam/icons": "^0.3.0"
44+
},
45+
"engines": {
46+
"node": ">=20.0.0"
4647
}
4748
}

postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: [
3+
require('postcss-nested-ancestors'),
4+
require('postcss-nested'),
5+
],
6+
};

src/index.pcss renamed to src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
padding: 6px;
2929
border-radius: 6px;
3030
margin: auto 0 auto auto;
31+
color: inherit;
3132

3233
&:hover {
3334
background: var(--color-bg-secondary--hover);

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './index.pcss';
1+
import './index.css';
22

33
import Uploader from './uploader';
44
import { make, moveCaretToTheEnd, isEmpty } from './utils/dom';

0 commit comments

Comments
 (0)