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",
|
"name": "widget",
|
||||||
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
|
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({
|
export default defineConfig({
|
||||||
plugins: [cssInjectedByJsPlugin()],
|
plugins: [cssInjectedByJsPlugin()],
|
||||||
resolve: {
|
resolve: {
|
||||||
@@ -19,6 +23,7 @@ export default defineConfig({
|
|||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
exports: 'named',
|
exports: 'named',
|
||||||
|
banner,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user