improved build system, fixed special character escaping bug
This commit is contained in:
parent
9de822f5a2
commit
5f63dc7c7d
@ -15,6 +15,16 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/build.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
|
@ -25,11 +25,16 @@ let commands = [
|
||||
let commandIdx = 0;
|
||||
|
||||
function executeCommand(commandIdx) {
|
||||
console.log("Executing: " + commands[commandIdx].toString().replace(/\(\) => child_process\.fork/g, '').replace(/\(|\)$/g, ''));
|
||||
let process = commands[commandIdx]();
|
||||
process.on('close', (exitCode) => {
|
||||
if(exitCode != 0) throw "Command " + commands[commandIdx] + " failed with code " + exitCode;
|
||||
commandIdx += 1;
|
||||
if(commandIdx == commands.length) return;
|
||||
if(commandIdx == commands.length)
|
||||
{
|
||||
console.log("Done.");
|
||||
return;
|
||||
}
|
||||
executeCommand(commandIdx);
|
||||
});
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
let fs = require('fs')
|
||||
|
||||
function escapeTemplateLiteral(str) {
|
||||
return str.replace(/([\\$`])/g, '\\$1');
|
||||
}
|
||||
|
||||
function embedHtml(src, dst) {
|
||||
fs.readFile(src, 'utf8', function(err, data) {
|
||||
if(err) throw err;
|
||||
|
||||
data = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `" + data + "`;";
|
||||
data = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `" + escapeTemplateLiteral(data) + "`;";
|
||||
|
||||
fs.writeFile(dst, data, function(err) {
|
||||
if(err) throw err;
|
||||
@ -16,7 +20,7 @@ function embedCss(src, dst) {
|
||||
fs.readFile(src, 'utf8', function(err, data) {
|
||||
if(err) throw err;
|
||||
|
||||
data = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `<style>" + data + "</style>`;";
|
||||
data = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `<style>" + escapeTemplateLiteral(data) + "</style>`;";
|
||||
data = data.replace(/"/g, "'");
|
||||
|
||||
fs.writeFile(dst, data, function(err) {
|
||||
@ -36,7 +40,7 @@ function embedSvg(src, dst) {
|
||||
data = data.replace(/<\/attributes><\/desc>/g, '>');
|
||||
data = data.replace(/"/g, '"');
|
||||
|
||||
data = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `" + data + "`;";
|
||||
data = "(<any>window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `" + escapeTemplateLiteral(data) + "`;";
|
||||
|
||||
fs.writeFile(dst, data, function(err) {
|
||||
if(err) throw err;
|
||||
|
@ -6,13 +6,11 @@ let content = ['./*.html'];
|
||||
// Reference of all CSS files from root directory
|
||||
let css = ['3rdparty/bulma/css/bulma.css', './app/app.css'];
|
||||
|
||||
let files = {
|
||||
let options = {
|
||||
output: '../.intermediate/app.css',
|
||||
whitelist: ['is-multiple', 'is-loading', 'is-narrow', 'is-active', 'climate-zone'],
|
||||
minify: true,
|
||||
info: true
|
||||
info: false
|
||||
};
|
||||
|
||||
purify(content, css, files, function (purifiedAndMinifiedResult) {
|
||||
console.log(purifiedAndMinifiedResult);
|
||||
});
|
||||
purify(content, css, options);
|
||||
|
Loading…
Reference in New Issue
Block a user