Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Added build script

Blue Mouse69e0d6add496
diff --git a/package.json b/package.json
index 109ab8b1c..07a66b2b9 100644
--- a/package.json
+++ b/package.json
@@ -2,9 +2,17 @@
"name": "analytics_script",
"version": "1.0.0",
"description": "",
- "main": "index.js",
+ "main": "dist/analytics.cjs.js",
+ "module": "dist/analytics.es5.js",
+ "browser": "dist/analytics.umd.js",
+ "esnext": "dist/esnext/index.js",
+ "typings": "dist/esnext/index.d.ts",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "prebuild": "rimraf dist",
+ "prepublish": "npm run build",
+ "build": "rollup -c && tsc -p tsconfig.esnext.json",
+ "start": "rollup -c -w",
+ "tsc": "tsc -p tsconfig.esnext.json"
},
"repository": {
"type": "git",
@@ -17,7 +25,17 @@
},
"homepage": "https://github.com/Blaumaus/analytics_script#readme",
"dependencies": {
- "@types/node": "^14.14.41",
- "typescript": "^4.2.4"
+ "@types/node": "^14.14.41"
+ },
+ "devDependencies": {
+ "rimraf": "^3.0.2",
+ "rollup": "^2.53.0",
+ "rollup-plugin-commonjs": "^10.1.0",
+ "rollup-plugin-json": "^4.0.0",
+ "rollup-plugin-node-resolve": "^5.2.0",
+ "rollup-plugin-sourcemaps": "^0.6.3",
+ "rollup-plugin-typescript2": "^0.30.0",
+ "rollup-plugin-uglify": "^6.0.4",
+ "typescript": "^4.3.5"
}
}
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 000000000..0a57b71e2
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,29 @@
+import resolve from 'rollup-plugin-node-resolve'
+import commonjs from 'rollup-plugin-commonjs'
+import sourceMaps from 'rollup-plugin-sourcemaps'
+import typescript from 'rollup-plugin-typescript2'
+import { uglify } from 'rollup-plugin-uglify'
+import pkg from './package.json'
+
+export default [
+ {
+ input: 'src/index.ts',
+ output: [
+ { file: pkg.browser, format: 'umd', name: 'analytics' },
+ { file: pkg.main, format: 'cjs' },
+ { file: pkg.module, format: 'es' },
+ ],
+ plugins: [
+ typescript(), resolve(), commonjs(), sourceMaps(),
+ ]
+ },
+ {
+ input: 'src/index.ts',
+ output: [
+ { file: 'dist/analytics.umd.min.js', format: 'umd', name: 'analytics' },
+ ],
+ plugins: [
+ typescript(), resolve(), commonjs(), uglify(),
+ ]
+ }
+]
diff --git a/tsconfig.esnext.json b/tsconfig.esnext.json
new file mode 100644
index 000000000..901fb91ab
--- /dev/null
+++ b/tsconfig.esnext.json
@@ -0,0 +1,17 @@
+{
+ "compilerOptions": {
+ "moduleResolution": "node",
+ "target": "es2020",
+ "module": "es2015",
+ "lib": ["dom"],
+ "strict": true,
+ "sourceMap": true,
+ "declaration": true,
+ "allowSyntheticDefaultImports": true,
+ "experimentalDecorators": true,
+ "emitDecoratorMetadata": true,
+ "outDir": "dist/esnext",
+ "typeRoots": ["node_modules/@types"]
+ },
+ "include": ["src"]
+}
diff --git a/tsconfig.json b/tsconfig.json
index c09c361cd..3fe10f8db 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -14,4 +14,4 @@
"typeRoots": ["node_modules/@types"]
},
"include": ["src"]
-}
\ No newline at end of file
+}