feat: remove iife-full build
This commit is contained in:
@@ -37,10 +37,9 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://alibaba.github.io/page-agent/",
|
"homepage": "https://alibaba.github.io/page-agent/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build && npm run build:iife && npm run build:demo",
|
"build": "vite build && npm run build:demo",
|
||||||
"build:iife": "vite build --config vite.iife.config.js",
|
"build:demo": "vite build --config vite.iife.config.js",
|
||||||
"build:demo": "vite build --config vite.iife.config.js --mode demo",
|
"dev:demo": "concurrently \"vite build --config vite.iife.config.js --watch\" \"npx serve dist/iife -p 5174\"",
|
||||||
"dev:iife": "concurrently \"vite build --config vite.iife.config.js --watch --mode demo\" \"npx serve dist/iife -p 5174\"",
|
|
||||||
"prepublishOnly": "node -e \"const fs=require('fs');['README.md','LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
"prepublishOnly": "node -e \"const fs=require('fs');['README.md','LICENSE'].forEach(f=>fs.copyFileSync('../../'+f,f))\"",
|
||||||
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* IIFE demo entry - auto-initializes with built-in demo API for testing
|
* IIFE demo entry - auto-initializes with built-in demo API for testing
|
||||||
*/
|
*/
|
||||||
import { PageAgent, type PageAgentConfig } from '../PageAgent'
|
import { PageAgent, type PageAgentConfig } from './PageAgent'
|
||||||
|
|
||||||
// Clean up existing instances to prevent multiple injections from bookmarklet
|
// Clean up existing instances to prevent multiple injections from bookmarklet
|
||||||
if (window.pageAgent) {
|
if (window.pageAgent) {
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/**
|
|
||||||
* IIFE entry
|
|
||||||
*/
|
|
||||||
import { PageAgent } from '../PageAgent'
|
|
||||||
|
|
||||||
// Mount to global window object
|
|
||||||
window.PageAgent = PageAgent
|
|
||||||
|
|
||||||
export { PageAgent }
|
|
||||||
@@ -14,56 +14,44 @@ dotenvConfig({ path: resolve(__dirname, '../../.env') })
|
|||||||
// - alias all local packages so that they can be build in
|
// - alias all local packages so that they can be build in
|
||||||
// - no external
|
// - no external
|
||||||
// - no d.ts. dts does not work with monorepo aliasing
|
// - no d.ts. dts does not work with monorepo aliasing
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => ({
|
||||||
const isDemo = mode === 'demo'
|
plugins: [cssInjectedByJsPlugin({ relativeCSSInjection: true })],
|
||||||
const entry = isDemo
|
publicDir: false,
|
||||||
? resolve(__dirname, 'src/iife/page-agent.demo.ts')
|
esbuild: {
|
||||||
: resolve(__dirname, 'src/iife/page-agent.ts')
|
keepNames: true,
|
||||||
const fileName = isDemo ? 'page-agent.demo' : 'page-agent'
|
},
|
||||||
|
resolve: {
|
||||||
return {
|
alias: {
|
||||||
plugins: [cssInjectedByJsPlugin({ relativeCSSInjection: true })],
|
'@page-agent/page-controller': resolve(__dirname, '../page-controller/src/PageController.ts'),
|
||||||
publicDir: false,
|
'@page-agent/llms': resolve(__dirname, '../llms/src/index.ts'),
|
||||||
esbuild: {
|
'@page-agent/core': resolve(__dirname, '../core/src/PageAgentCore.ts'),
|
||||||
keepNames: true,
|
'@page-agent/ui': resolve(__dirname, '../ui/src/index.ts'),
|
||||||
},
|
},
|
||||||
resolve: {
|
},
|
||||||
alias: {
|
build: {
|
||||||
'@page-agent/page-controller': resolve(
|
lib: {
|
||||||
__dirname,
|
entry: resolve(__dirname, 'src/demo.ts'),
|
||||||
'../page-controller/src/PageController.ts'
|
name: 'PageAgent',
|
||||||
),
|
fileName: () => `page-agent.demo.js`,
|
||||||
'@page-agent/llms': resolve(__dirname, '../llms/src/index.ts'),
|
formats: ['iife'],
|
||||||
'@page-agent/core': resolve(__dirname, '../core/src/PageAgentCore.ts'),
|
},
|
||||||
'@page-agent/ui': resolve(__dirname, '../ui/src/index.ts'),
|
outDir: resolve(__dirname, 'dist', 'iife'),
|
||||||
|
cssCodeSplit: true,
|
||||||
|
// minify: false,
|
||||||
|
rollupOptions: {
|
||||||
|
// output: {
|
||||||
|
// // force use .js as extension
|
||||||
|
// entryFileNames: 'page-agent.js',
|
||||||
|
// },
|
||||||
|
onwarn: function (message, handler) {
|
||||||
|
if (message.code === 'EVAL') return
|
||||||
|
handler(message)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
},
|
||||||
lib: {
|
define: {
|
||||||
entry,
|
'import.meta.env.LLM_MODEL_NAME': JSON.stringify(process.env.LLM_MODEL_NAME),
|
||||||
name: 'PageAgent',
|
'import.meta.env.LLM_API_KEY': JSON.stringify(process.env.LLM_API_KEY),
|
||||||
fileName: () => `${fileName}.js`,
|
'import.meta.env.LLM_BASE_URL': JSON.stringify(process.env.LLM_BASE_URL),
|
||||||
formats: ['iife'],
|
},
|
||||||
},
|
}))
|
||||||
outDir: resolve(__dirname, 'dist', 'iife'),
|
|
||||||
emptyOutDir: !isDemo, // only empty on first build
|
|
||||||
cssCodeSplit: true,
|
|
||||||
minify: false,
|
|
||||||
rollupOptions: {
|
|
||||||
// output: {
|
|
||||||
// // force use .js as extension
|
|
||||||
// entryFileNames: 'page-agent.js',
|
|
||||||
// },
|
|
||||||
onwarn: function (message, handler) {
|
|
||||||
if (message.code === 'EVAL') return
|
|
||||||
handler(message)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
define: {
|
|
||||||
'import.meta.env.LLM_MODEL_NAME': JSON.stringify(process.env.LLM_MODEL_NAME),
|
|
||||||
'import.meta.env.LLM_API_KEY': JSON.stringify(process.env.LLM_API_KEY),
|
|
||||||
'import.meta.env.LLM_BASE_URL': JSON.stringify(process.env.LLM_BASE_URL),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user