Vars target from #vars decl.
This commit is contained in:
parent
47bd2fab87
commit
b07c088ab7
2 changed files with 2 additions and 3 deletions
|
@ -57,6 +57,7 @@ module.exports.folder = async (root, options) => {
|
||||||
if(typeof options.vars !== 'object' || options.vars === null)
|
if(typeof options.vars !== 'object' || options.vars === null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
const bvTarget = args.shift();
|
||||||
const bvSourceName = trimEnd(args.join(' '), ';');
|
const bvSourceName = trimEnd(args.join(' '), ';');
|
||||||
const bvSource = options.vars[bvSourceName];
|
const bvSource = options.vars[bvSourceName];
|
||||||
if(typeof bvSource !== 'objects' || bvSource === null)
|
if(typeof bvSource !== 'objects' || bvSource === null)
|
||||||
|
@ -67,7 +68,7 @@ module.exports.folder = async (root, options) => {
|
||||||
bvProps.push(`${bvName}: { value: ${JSON.stringify(bvSource[bvName])} }`);
|
bvProps.push(`${bvName}: { value: ${JSON.stringify(bvSource[bvName])} }`);
|
||||||
|
|
||||||
if(Object.keys(bvProps).length > 0)
|
if(Object.keys(bvProps).length > 0)
|
||||||
output += `Object.defineProperties(${options.varsTarget}, { ${bvProps.join(', ')} });\n`;
|
output += `Object.defineProperties(${bvTarget}, { ${bvProps.join(', ')} });\n`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -7,7 +7,6 @@ const { strtr, shortHash, writeFile } = require('../utils.js');
|
||||||
module.exports = function(env) {
|
module.exports = function(env) {
|
||||||
const PREFIX = '#';
|
const PREFIX = '#';
|
||||||
const DEFAULT_ENTRY = 'main.js';
|
const DEFAULT_ENTRY = 'main.js';
|
||||||
const DEFAULT_VARS_TARGET = 'window';
|
|
||||||
|
|
||||||
const createJscOpts = () => {
|
const createJscOpts = () => {
|
||||||
return {
|
return {
|
||||||
|
@ -50,7 +49,6 @@ module.exports = function(env) {
|
||||||
prefix: PREFIX,
|
prefix: PREFIX,
|
||||||
entry: task.entry ?? DEFAULT_ENTRY,
|
entry: task.entry ?? DEFAULT_ENTRY,
|
||||||
vars: vars,
|
vars: vars,
|
||||||
varsTarget: task.varsTarget ?? DEFAULT_VARS_TARGET,
|
|
||||||
}), {
|
}), {
|
||||||
filename: task.source,
|
filename: task.source,
|
||||||
sourceMaps: false,
|
sourceMaps: false,
|
||||||
|
|
Loading…
Reference in a new issue