From e42603e832ff1dcf601f050a2b24f96d60cfc52d Mon Sep 17 00:00:00 2001 From: chengpeiquan Date: Thu, 8 Dec 2022 10:21:32 +0800 Subject: [PATCH] feat: Comments are no longer automatically added when the erify option is turned off --- package.json | 2 +- src/main.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 986e818..4e05f33 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vite-plugin-banner", "description": "A banner plugin for Vite. Adds a banner to the top of each generated chunk.", - "version": "0.6.1", + "version": "0.7.0", "author": "chengpeiquan ", "license": "MIT", "homepage": "https://github.com/chengpeiquan/vite-plugin-banner", diff --git a/src/main.ts b/src/main.ts index 29d17bb..3f1b928 100644 --- a/src/main.ts +++ b/src/main.ts @@ -60,20 +60,27 @@ export default function ( let data: string = fs.readFileSync(filePath, { encoding: 'utf8', }) + let myContent: string = typeof setContent === 'string' ? setContent : '' if (typeof setContent === 'function') { myContent = setContent(fileName) if (!myContent) return } + // If the banner content has comment symbol, use it directly - if (myContent.includes('/*') || myContent.includes('*/')) { + if ( + myContent.includes('/*') || + myContent.includes('*/') || + !pluginConfig.verify + ) { data = `${myContent}\n${data}` } // Otherwise add comment symbol else { data = `/*! ${myContent} */\n${data}` } + // Save fs.writeFileSync(filePath, data) } catch (e) {