Merge banner.js into Rake task

Also let uglify-js produce source map for easier debugging
This commit is contained in:
iBug 2024-05-05 04:13:39 +08:00
parent 0b8b5230f9
commit b278dac7fb
3 changed files with 4 additions and 11 deletions

View File

@ -155,9 +155,9 @@ CLEAN.include(*COPYRIGHT_FILES)
JS_FILES = Dir.glob("assets/js/plugins/*.js") + ["assets/js/_main.js"]
JS_TARGET = "assets/js/main.min.js"
task :js => JS_TARGET
file JS_TARGET => JS_FILES do |t|
sh Shellwords.join(%w[npx uglifyjs -c -m -o] + [t.name] + t.prerequisites)
sh "node banner.js"
file JS_TARGET => ["_includes/copyright.js"] + JS_FILES do |t|
sh Shellwords.join(%w[npx uglifyjs -c --comments /@mmistakes/ --source-map -m -o] +
[t.name] + t.prerequisites)
end
task :watch_js do

File diff suppressed because one or more lines are too long

View File

@ -1,8 +0,0 @@
const fs = require("fs");
const filename = "assets/js/main.min.js"
const script = fs.readFileSync(filename);
const banner = fs.readFileSync("_includes/copyright.js");
if (script.slice(0, 3) != "/*!") {
fs.writeFileSync(filename, banner + script);
}