mirror of
https://github.com/plausible/analytics.git
synced 2024-12-28 03:54:23 +03:00
fb7a3fef89
* Adds data-exclude support and plausible_ignore support * Splits exclusion into separate script option * localStorage parsing upgrades * Additional script type additions I'm unsure about the formatting decision in tracker.ex - lmk. * Adds new compiled files This will certainly have conflicts with my other PRs related to the tracking scripts right now, I'll make one extra PR after both are done to ensure they're consolidated into the compiled scripts. * Moves localStorage blocker out of special script * Changelog * Second thoughts on localStorage exclusion * Updates `*` to not match `/` or whitespace * Fix formatting * Removes zero-length asterisks * Adds support for double glob, zero-length replacements * Update to reduce size+allow localStorage exclude Co-authored-by: Uku Taht <Uku.taht@gmail.com>
28 lines
1.7 KiB
JavaScript
28 lines
1.7 KiB
JavaScript
const uglify = require("uglify-js");
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
const Handlebars = require("handlebars");
|
|
|
|
function relPath(segment) {
|
|
return path.join(__dirname, segment)
|
|
}
|
|
|
|
function compilefile(input, output, templateVars = {}) {
|
|
const code = fs.readFileSync(input).toString()
|
|
const template = Handlebars.compile(code)
|
|
const rendered = template(templateVars)
|
|
const result = uglify.minify(rendered)
|
|
fs.writeFileSync(output, result.code)
|
|
}
|
|
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.js'))
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.exclusions.js'), {exclusionMode: true})
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.hash.js'), {hashMode: true})
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.hash.exclusions.js'), {hashMode: true, exclusionMode: true})
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.outbound-links.js'), {outboundLinks: true})
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.exclusions.outbound-links.js'), {outboundLinks: true, exclusionMode: true})
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.hash.outbound-links.js'), {hashMode: true, outboundLinks: true})
|
|
compilefile(relPath('src/plausible.js'), relPath('../priv/tracker/js/plausible.hash.exclusions.outbound-links.js'), {hashMode: true, outboundLinks: true, exclusionMode: true})
|
|
compilefile(relPath('src/p.js'), relPath('../priv/tracker/js/p.js'))
|
|
fs.copyFileSync(relPath('../priv/tracker/js/plausible.js'), relPath('../priv/tracker/js/analytics.js'))
|