build(widget): 添加版本号并配置构建banner
在package.json中添加版本号字段,并在vite配置中读取版本号生成构建banner,用于标识构建产物版本
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "widget",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
|
||||
|
||||
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf-8'));
|
||||
const banner = `/*! CWDComments widget v${pkg.version} */`;
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [cssInjectedByJsPlugin()],
|
||||
resolve: {
|
||||
@@ -19,6 +23,7 @@ export default defineConfig({
|
||||
rollupOptions: {
|
||||
output: {
|
||||
exports: 'named',
|
||||
banner,
|
||||
},
|
||||
},
|
||||
sourcemap: false,
|
||||
|
||||
Reference in New Issue
Block a user