Compare commits
3 commits
36414468dc
...
b07c088ab7
Author | SHA1 | Date | |
---|---|---|---|
b07c088ab7 | |||
47bd2fab87 | |||
99b8f4919b |
5 changed files with 8 additions and 11 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@flashwave/assproc",
|
||||
"version": "0.11.0",
|
||||
"version": "0.12.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@flashwave/assproc",
|
||||
"version": "0.11.0",
|
||||
"version": "0.12.0",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"@swc/core": "^1.5.25",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@flashwave/assproc",
|
||||
"version": "0.11.0",
|
||||
"version": "0.12.0",
|
||||
"description": "Personal frontend asset processing tool",
|
||||
"main": "./src/index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -57,6 +57,7 @@ module.exports.folder = async (root, options) => {
|
|||
if(typeof options.vars !== 'object' || options.vars === null)
|
||||
break;
|
||||
|
||||
const bvTarget = args.shift();
|
||||
const bvSourceName = trimEnd(args.join(' '), ';');
|
||||
const bvSource = options.vars[bvSourceName];
|
||||
if(typeof bvSource !== 'objects' || bvSource === null)
|
||||
|
@ -67,7 +68,7 @@ module.exports.folder = async (root, options) => {
|
|||
bvProps.push(`${bvName}: { value: ${JSON.stringify(bvSource[bvName])} }`);
|
||||
|
||||
if(Object.keys(bvProps).length > 0)
|
||||
output += `Object.defineProperties(${options.varsTarget}, { ${bvProps.join(', ')} });\n`;
|
||||
output += `Object.defineProperties(${bvTarget}, { ${bvProps.join(', ')} });\n`;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -7,7 +7,6 @@ const { strtr, shortHash, writeFile } = require('../utils.js');
|
|||
module.exports = function(env) {
|
||||
const PREFIX = '#';
|
||||
const DEFAULT_ENTRY = 'main.js';
|
||||
const DEFAULT_VARS_TARGET = 'window';
|
||||
|
||||
const createJscOpts = () => {
|
||||
return {
|
||||
|
@ -50,7 +49,6 @@ module.exports = function(env) {
|
|||
prefix: PREFIX,
|
||||
entry: task.entry ?? DEFAULT_ENTRY,
|
||||
vars: vars,
|
||||
varsTarget: task.varsTarget ?? DEFAULT_VARS_TARGET,
|
||||
}), {
|
||||
filename: task.source,
|
||||
sourceMaps: false,
|
||||
|
|
|
@ -33,9 +33,6 @@ module.exports.process = async (env, tasks) => {
|
|||
const files = {};
|
||||
|
||||
for(const type of order) {
|
||||
if(!types.hasOwnProperty(type))
|
||||
continue;
|
||||
|
||||
if(!(type in types))
|
||||
throw `${type} is not a supported build task type`;
|
||||
|
||||
|
@ -54,8 +51,9 @@ module.exports.process = async (env, tasks) => {
|
|||
console.info(` => ${task.source}...`);
|
||||
const path = await handler.process(task, vars);
|
||||
|
||||
if(typeof task.varsName === 'string')
|
||||
vars[task.varsGroup ?? ''][task.varsName] = path;
|
||||
if(typeof task.vars === 'object' && task.vars !== null)
|
||||
for(const varsGroup in task.vars)
|
||||
vars[varsGroup][task.vars[varsGroup] === ':source' ? task.source : task.vars[varsGroup]] = path;
|
||||
|
||||
files[task.source] = path;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue