New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-html-env

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-html-env - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

53

lib/index.js

@@ -30,2 +30,4 @@ "use strict";

const REGEXP_SYNTAX_CHARACTER = /[\[\]\(\)\.\+\^\$\*\!]/g;
const _omit = (obj = {}, uselessKeys = []) => {

@@ -95,3 +97,4 @@ return Object.keys(obj || {}).reduce((cur, key) => {

envPrefixes: 'VITE_',
compiler: true
compiler: true,
enforce: null
};

@@ -101,24 +104,13 @@

let cacheEnvDir = '';
return {
name: 'rollup-plugin-html-env',
config = config || {};
config(cfg) {
if (cfg && cfg.envDir) {
cacheEnvDir = cfg && cfg.envDir;
} else {
// The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root.
// https://vitejs.dev/config/shared-options.html#envdir
cacheEnvDir = cfg.root || '';
}
},
let _pick2 = _pick(config, DEFAULT_CONFIG),
prefix = _pick2.prefix,
suffix = _pick2.suffix,
envPrefixes = _pick2.envPrefixes,
compiler = _pick2.compiler,
enforce = _pick2.enforce;
transformIndexHtml(html, ctx) {
config = config || {};
const _pick2 = _pick(config, DEFAULT_CONFIG),
prefix = _pick2.prefix,
suffix = _pick2.suffix,
envPrefixes = _pick2.envPrefixes,
compiler = _pick2.compiler;
let transformIndexHtml = {
transform(html, ctx) {
let ctxEnvConfig = {}; // Use the loadEnv method provided by vite, because the code checks that it is a dev environment

@@ -136,2 +128,5 @@

prefix = prefix.replace(REGEXP_SYNTAX_CHARACTER, (...arg) => `\\${arg[0]}`);
suffix = suffix.replace(REGEXP_SYNTAX_CHARACTER, (...arg) => `\\${arg[0]}`);
if (compiler) {

@@ -154,4 +149,20 @@ const parseHtml = new ParseHTML(html, _objectSpread(_objectSpread({}, map), {}, {

};
if (enforce) transformIndexHtml.enforce = enforce;
return {
name: 'rollup-plugin-html-env',
config(cfg) {
if (cfg && cfg.envDir) {
cacheEnvDir = cfg && cfg.envDir;
} else {
// The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root.
// https://vitejs.dev/config/shared-options.html#envdir
cacheEnvDir = cfg.root || '';
}
},
transformIndexHtml
};
}
module.exports = vitePluginHtmlEnv;

@@ -19,3 +19,3 @@ "use strict";

const DOCTYPE_REG = /^<!DOCTYPE [^>]+>/i;
const LETTER_REG = /[a-zA-Z\-]/;
const LETTER_REG = /[a-zA-Z\-@\.]/;
const EMPTY_REG = /[\s\n]/;

@@ -120,5 +120,5 @@ const NUMBER_REG = /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/;

this.html = this.html.replace(/[\s]*=[\s]*"/g, '="');
const _this$options = this.options,
prefix = _this$options.prefix,
suffix = _this$options.suffix;
let _this$options = this.options,
prefix = _this$options.prefix,
suffix = _this$options.suffix;
const reg = new RegExp(`(${prefix}|<%)\\s*([\\w\\-]+)\\s*(${suffix}|\/>)`, 'g');

@@ -125,0 +125,0 @@ this.html = this.html.replace(reg, (...arg) => `${this.options[arg[2]] || ''}`);

{
"name": "vite-plugin-html-env",
"version": "1.2.2",
"version": "1.2.3",
"description": "A vite plugin for rewriting html",

@@ -40,3 +40,3 @@ "files": [

"peerDependencies": {
"vite": "^2.1.3"
"vite": "*"
},

@@ -43,0 +43,0 @@ "devDependencies": {

@@ -6,2 +6,4 @@ const { loadEnv } = require('vite')

const REGEXP_SYNTAX_CHARACTER = /[\[\]\(\)\.\+\^\$\*\!]/g
const _omit = (obj = {}, uselessKeys = []) => {

@@ -82,3 +84,4 @@ return Object.keys(obj || {}).reduce((cur, key) => {

envPrefixes: 'VITE_',
compiler: true
compiler: true,
enforce: null
}

@@ -88,19 +91,7 @@

let cacheEnvDir = ''
config = config || {}
let { prefix, suffix, envPrefixes, compiler, enforce } = _pick(config, DEFAULT_CONFIG)
return {
name: 'rollup-plugin-html-env',
config (cfg) {
if (cfg && cfg.envDir) {
cacheEnvDir = cfg && cfg.envDir
} else {
// The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root.
// https://vitejs.dev/config/shared-options.html#envdir
cacheEnvDir = cfg.root || ''
}
},
transformIndexHtml (html, ctx) {
config = config || {}
const { prefix, suffix, envPrefixes, compiler } = _pick(config, DEFAULT_CONFIG)
let transformIndexHtml = {
transform (html, ctx) {
let ctxEnvConfig = {}

@@ -117,2 +108,5 @@ // Use the loadEnv method provided by vite, because the code checks that it is a dev environment

prefix = prefix.replace(REGEXP_SYNTAX_CHARACTER, (...arg) => `\\${arg[0]}`)
suffix = suffix.replace(REGEXP_SYNTAX_CHARACTER, (...arg) => `\\${arg[0]}`)
if (compiler) {

@@ -137,4 +131,22 @@ const parseHtml = new ParseHTML(html, {

}
if (enforce) transformIndexHtml.enforce = enforce
return {
name: 'rollup-plugin-html-env',
config (cfg) {
if (cfg && cfg.envDir) {
cacheEnvDir = cfg && cfg.envDir
} else {
// The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root.
// https://vitejs.dev/config/shared-options.html#envdir
cacheEnvDir = cfg.root || ''
}
},
transformIndexHtml
}
}
module.exports = vitePluginHtmlEnv
const { removeComments } = require("../utils")
const DOCTYPE_REG = /^<!DOCTYPE [^>]+>/i
const LETTER_REG = /[a-zA-Z\-]/
const LETTER_REG = /[a-zA-Z\-@\.]/
const EMPTY_REG = /[\s\n]/

@@ -66,3 +66,3 @@ const NUMBER_REG = /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/

// node
// node
this.node = null

@@ -76,3 +76,3 @@ this.current = null

preHandle() {
preHandle () {
// Clear the html comments

@@ -92,3 +92,4 @@ this.html = this.html.replace(/<!\-\-.+\-\->/g, '')

const { prefix, suffix } = this.options
let { prefix, suffix } = this.options
const reg = new RegExp(`(${prefix}|<%)\\s*([\\w\\-]+)\\s*(${suffix}|\/>)`, 'g')

@@ -100,3 +101,3 @@

advance(n) {
advance (n) {
this.index += n

@@ -303,3 +304,3 @@ this.html = this.html.substring(n)

if (!this.text) return
this.current.children.push(createNode({ tag: '', text: this.text.trim(), type: 'textNode'}))
this.current.children.push(createNode({ tag: '', text: this.text.trim(), type: 'textNode' }))
this.text = ''

@@ -412,3 +413,3 @@ }

if (type === 'textNode') {
if ( this.checkOnlyOneTextNode(parent)) return
if (this.checkOnlyOneTextNode(parent)) return
html += '\n'

@@ -415,0 +416,0 @@ return

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc