打包html的内容类型
This commit is contained in:
parent
53b286ef99
commit
45dc0c422c
15
package.json
15
package.json
@ -5,11 +5,24 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"build": "rollup -c",
|
||||||
|
"build:app": "rsync dist/* ../deploy/dist"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-commonjs": "^28.0.1",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
|
"@rollup/plugin-typescript": "^12.1.1",
|
||||||
|
"@types/crypto-js": "^4.2.2",
|
||||||
|
"@types/react": "^18.3.12",
|
||||||
|
"rimraf": "^6.0.1",
|
||||||
|
"rollup": "^4.24.3",
|
||||||
|
"rollup-plugin-copy": "^3.5.0",
|
||||||
|
"rollup-plugin-dts": "^6.1.1",
|
||||||
|
"typescript": "^5.6.3"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lit-html": "^3.2.1"
|
"lit-html": "^3.2.1"
|
||||||
}
|
}
|
||||||
|
47
rollup.config.js
Normal file
47
rollup.config.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// rollup.config.js
|
||||||
|
|
||||||
|
import typescript from '@rollup/plugin-typescript';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
import copy from 'rollup-plugin-copy';
|
||||||
|
import { dts } from 'rollup-plugin-dts';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('rollup').RollupOptions}
|
||||||
|
*/
|
||||||
|
const config1 = {
|
||||||
|
input: 'src/index.ts', // TypeScript 入口文件
|
||||||
|
output: {
|
||||||
|
file: 'dist/html.js', // 输出文件
|
||||||
|
format: 'es', // 输出格式设置为 ES 模块
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
browser: true, // 若为浏览器环境,设为 true;若为 Node.js 环境,设为 false
|
||||||
|
preferBuiltins: false, // 优先使用内置模块
|
||||||
|
}), // 使用 @rollup/plugin-node-resolve 解析 node_modules 中的模块
|
||||||
|
// commonjs(), //
|
||||||
|
|
||||||
|
typescript({
|
||||||
|
allowImportingTsExtensions: true,
|
||||||
|
noEmit: true,
|
||||||
|
declaration: false,
|
||||||
|
}), // 使用 @rollup/plugin-typescript 处理 TypeScript 文件
|
||||||
|
],
|
||||||
|
include: ['node_modules/**'],
|
||||||
|
external: [],
|
||||||
|
};
|
||||||
|
const config1Dts = {
|
||||||
|
input: 'src/index.ts', // TypeScript 入口文件
|
||||||
|
output: {
|
||||||
|
file: 'dist/html.d.ts', // 输出文件
|
||||||
|
format: 'es', // 输出格式设置为 ES 模块
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
dts(), // 生成 .d.ts 类型声明文件
|
||||||
|
],
|
||||||
|
external: [],
|
||||||
|
include: ['node_modules/**'],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default [config1, config1Dts];
|
3
src/index.ts
Normal file
3
src/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from 'lit-html';
|
||||||
|
|
||||||
|
export type { render, html, svg, nothing } from 'lit-html';
|
23
tsconfig.json
Normal file
23
tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ESNext",
|
||||||
|
"lib": [
|
||||||
|
"ES2020",
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable"
|
||||||
|
],
|
||||||
|
"noEmit": false,
|
||||||
|
"outDir": "dist",
|
||||||
|
"strict": false,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"rootDir": "src",
|
||||||
|
"noUnusedLocals": false,
|
||||||
|
"noUnusedParameters": false,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user