Skip to content

Commit 71f22d6

Browse files
authored
Merge pull request #39 from EDMdesigner/release/cdn-build
feat: cdn build
2 parents 8c335f1 + ff7d01e commit 71f22d6

File tree

7 files changed

+107
-35
lines changed

7 files changed

+107
-35
lines changed

.github/workflows/npm-publish.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,34 @@ jobs:
1616
- uses: actions/setup-node@v2
1717
with:
1818
node-version: 22
19+
- name: Extract version
20+
id: extract_version
21+
uses: Saionaro/extract-package-version@v1.0.6
1922
- run: npm ci
2023
- run: npm test
2124
- run: npm run build
22-
- uses: JS-DevTools/npm-publish@v1
25+
- name: publish to npm (master)
26+
if: ${{ github.ref == 'refs/heads/master' }}
27+
uses: JS-DevTools/npm-publish@v1
2328
with:
2429
access: public
2530
token: ${{ secrets.NPM_TOKEN }}
31+
- name: publish to npm (env)
32+
if: contains(github.ref, 'environment')
33+
uses: JS-DevTools/npm-publish@v1
34+
with:
35+
access: public
36+
token: ${{ secrets.NPM_TOKEN }}
37+
tag: 'next'
38+
- run: npm run build-s3
39+
- name: publish to CDN (s3)
40+
uses: jakejarvis/s3-sync-action@master
41+
with:
42+
args: --acl public-read
43+
env:
44+
SOURCE_DIR: './dist'
45+
DEST_DIR: 'plugin-interface/${{ steps.extract_version.outputs.version }}'
46+
AWS_REGION: 'us-east-1'
47+
AWS_S3_BUCKET: ${{ secrets.DEPLOY_S3_BUCKET }}
48+
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_API_KEY }}
49+
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_SECRET }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

4+
## [1.1.3] 2025-08-11
5+
### Changed
6+
- Added CDN deploy
7+
48
## [1.1.2] 2025-02-18
59
### Changed
610
- node version 22

config/npm.cjs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
// config options
5+
build: {
6+
outDir: "./dist",
7+
target: "es2015",
8+
sourcemap: true,
9+
lib: {
10+
entry: path.resolve(__dirname, "../src/main.js"),
11+
name: "window.pluginInterface",
12+
fileName: (format) => {
13+
if (format === "umd") return "pluginInterface.cjs";
14+
return "pluginInterface.js";
15+
},
16+
},
17+
},
18+
test: {
19+
globals: true,
20+
mockClear: true,
21+
environment: "jsdom",
22+
silent: true,
23+
setupFiles: [
24+
// "./test/setupFile.js",
25+
],
26+
coverage: {
27+
100: false,
28+
},
29+
// outputDiffLines: Infinity,
30+
// outputDiffMaxLines: Infinity,
31+
// outputDiffMaxSize: Infinity,
32+
// outputTruncateLength: Infinity,
33+
},
34+
};

config/s3-es.cjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
// config options
5+
build: {
6+
outDir: "./dist/es/",
7+
target: "es2015",
8+
sourcemap: true,
9+
lib: {
10+
entry: path.resolve(__dirname, "../src/main.js"),
11+
name: "window.pluginInterface",
12+
formats: [ "es" ],
13+
fileName: () => "pluginInterface.js",
14+
},
15+
},
16+
};

config/s3-umd.cjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
// config options
5+
build: {
6+
outDir: "./dist/umd/",
7+
target: "es2015",
8+
sourcemap: true,
9+
lib: {
10+
entry: path.resolve(__dirname, "../src/main.js"),
11+
name: "window.pluginInterface",
12+
formats: [ "umd" ],
13+
fileName: () => "pluginInterface.js",
14+
},
15+
},
16+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chamaileon-sdk/plugin-interface",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"keywords": [
55
"postMessage",
66
"interface",

vite.config.cjs

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,14 @@
11
// vite.config.js
2-
const path = require("path");
3-
const { defineConfig } = require("vite");
2+
const { defineConfig, loadEnv } = require("vite");
43

5-
module.exports = defineConfig({
6-
// config options
7-
build: {
8-
outDir: "./dist",
9-
target: "es2015",
10-
sourcemap: true,
11-
lib: {
12-
entry: path.resolve(__dirname, "./src/main.js"),
13-
name: "pluginInterface",
14-
fileName: (format) => {
15-
if (format === "umd") return "pluginInterface.cjs";
16-
return "pluginInterface.js";
17-
},
18-
},
19-
},
20-
test: {
21-
globals: true,
22-
mockClear: true,
23-
environment: "jsdom",
24-
silent: true,
25-
setupFiles: [
26-
// "./test/setupFile.js",
27-
],
28-
coverage: {
29-
100: false,
30-
},
31-
// outputDiffLines: Infinity,
32-
// outputDiffMaxLines: Infinity,
33-
// outputDiffMaxSize: Infinity,
34-
// outputTruncateLength: Infinity,
35-
},
4+
module.exports = defineConfig(({ mode }) => {
5+
const env = loadEnv(mode, process.cwd(), "");
6+
if (env?.VITE_BUILD_TARGET === "s3-umd") {
7+
return require("./config/s3-umd.cjs");
8+
}
9+
if (env?.VITE_BUILD_TARGET === "s3-es") {
10+
return require("./config/s3-es.cjs");
11+
}
12+
13+
return require("./config/npm.cjs");
3614
});

0 commit comments

Comments
 (0)