Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let localSrcPath = realPath.modulePath || path.join(packagePath, relativeToDir);
let localRelativeToDir = relativeToDir;
if (realPath.modulePath) {
// recursively add resources
// TODO: async?
getResourcesOfPackage(resources, realPath.modulePath, undefined, overrideBlock || extractBundleResourceData(resource), realPath.moduleName);
if (moduleRootOverride[realPath.moduleName]) {
localRelativeToDir = moduleRootOverride[realPath.moduleName];
localSrcPath = path.join(realPath.modulePath, localRelativeToDir);
}
}
// is the initially resolved file an HTML file?
if (path.changeExt(realPath.source, 'html') !== realPath.source) {
// .html:
let fromPathHtml = path.addExt(fromPath, 'html');
if (!resources[fromPathHtml]) {
realPath = getRealPathUniversal(fromPathHtml, packagePath, relativeToDir);
if (realPath) {
debug(`<${path.basename(packagePath)}> ${realPath.path} => ${path.relative(packagePath, realPath.source)}`);
resources[fromPathHtml] = Object.assign({}, resource, realPath, overrideBlock || {});
}
}
}
if (realPath) {
// requested path was a html that needs analyzing for its own deps:
let htmlResources = resolveTemplateResources(realPath.source, localSrcPath, realPath.moduleName);
for (let htmlResource of htmlResources) {
processFromPath(resources, htmlResource.path, htmlResource, packagePath, localRelativeToDir, overrideBlock || extractBundleResourceData(htmlResource))
comparisons: false
},
parse: {},
mangle: true,
output: {
comments: false,
/* eslint-disable camelcase */
ascii_only: true
/* eslint-enable camelcase */
}
});
const path = await `${cli.flags.output}/` + file.substring(0, file.lastIndexOf('/'));
await makeDir(path);
fs.writeFile(`${cli.flags.output}/${upath.changeExt(file, '.min.js')}`, output.code).catch(err => {
if (err) {
spinner.fail('Error!\n' + err);
}
});
});
};
debug('<' + path.basename(packagePath) + '> ' + fromPath + ' => ' + path.relative(packagePath, realPath.source));
resources[fromPath] = (0, _assign2.default)({}, resource, realPath, overrideBlock || {});
var localSrcPath = realPath.modulePath || path.join(packagePath, relativeToDir);
var localRelativeToDir = relativeToDir;
if (realPath.modulePath) {
getResourcesOfPackage(resources, realPath.modulePath, undefined, overrideBlock || extractBundleResourceData(resource), realPath.moduleName);
if (moduleRootOverride[realPath.moduleName]) {
localRelativeToDir = moduleRootOverride[realPath.moduleName];
localSrcPath = path.join(realPath.modulePath, localRelativeToDir);
}
}
if (path.changeExt(realPath.source, 'html') !== realPath.source) {
var fromPathHtml = path.addExt(fromPath, 'html');
if (!resources[fromPathHtml]) {
realPath = getRealPathUniversal(fromPathHtml, packagePath, relativeToDir);
if (realPath) {
debug('<' + path.basename(packagePath) + '> ' + realPath.path + ' => ' + path.relative(packagePath, realPath.source));
resources[fromPathHtml] = (0, _assign2.default)({}, resource, realPath, overrideBlock || {});
}
}
}
if (realPath) {
var htmlResources = resolveTemplateResources(realPath.source, localSrcPath, realPath.moduleName);
for (var _iterator = htmlResources, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
});
const path = await `${cli.flags.output}/` + file.substring(0, file.lastIndexOf('/'));
await makeDir(path);
fs.writeFile(`${cli.flags.output}/${upath.changeExt(file, '.min.html')}`, output).catch(err => {
if (err) {
spinner.fail('Error!\n' + err);
}
});
});
};
await css.map(async file => {
const contents = await fs.readFile(file, 'utf8');
if (contents === '') {
return;
}
const output = await new CleanCSS().minify(contents);
const path = await `${cli.flags.output}/` + file.substring(0, file.lastIndexOf('/'));
await makeDir(path);
fs.writeFile(`${cli.flags.output}/${upath.changeExt(file, '.min.css')}`, output.styles).catch(err => {
if (err) {
spinner.fail('Error!\n' + err);
}
});
});
};