1+ /**
2+ * Removes all occurrences of a specified HTML tag and its contents from a string
3+ * @param {string } html - The HTML string to process
4+ * @param {string } tagName - The name of the tag to remove
5+ * @returns {string } The HTML string with all instances of the specified tag removed
6+ */
17function removetag ( html , tagName ) {
28 const pattern = new RegExp ( `<${ tagName } \\b[^>]*>([\\s\\S]*?)</${ tagName } >` , 'gi' )
39 // Repeatedly apply the regex until no more tags are found
@@ -7,13 +13,23 @@ function removetag(html, tagName) {
713 return html
814}
915
16+ /**
17+ * Removes all lines containing a specified string from a source text
18+ * @param {string } src - The source text to process
19+ * @param {string } tagName - The string to search for in each line
20+ * @returns {string } The source text with all lines containing the search string removed
21+ */
1022function removeline ( src , tagName ) {
1123 // Create a regular expression that matches any line containing the specified word
1224 const regex = new RegExp ( `^.*${ tagName } .*(?:\\r?\\n|\\r)?` , 'gim' )
1325 // Replace all occurrences of lines containing the word with an empty string
1426 return src . replace ( regex , '' )
1527}
1628
29+ /**
30+ * Creates a Vite plugin that strips development tools and components based on build mode
31+ * @returns {import('vite').Plugin } A Vite plugin object that transforms App.vue and SmileApp.vue files
32+ */
1733export default function stripDevToolPlugin ( ) {
1834 let config
1935 const loaderMatch = / ( A p p \. v u e | S m i l e A p p \. v u e ) $ /
@@ -26,6 +42,7 @@ export default function stripDevToolPlugin() {
2642
2743 transform ( src , id ) {
2844 if ( loaderMatch . test ( id ) ) {
45+ console . log ( ' ➜ stripping dev/present mode components from' , id . split ( '/' ) . slice ( - 3 ) . join ( '/' ) )
2946 let clean_src = src
3047
3148 // Handle App.vue specific removals
0 commit comments