Skip to content

Commit

Permalink
inject version into minified build; fixes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
kcargile committed Sep 10, 2024
1 parent 4af2528 commit f5c583e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.log
*.tsbuildinfo
*.d.ts
*.pem
*.tgz
.data
Expand Down
1 change: 1 addition & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const TB_VERSION: string | undefined;
2 changes: 2 additions & 0 deletions src/textblock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export interface TextblockTarget {
* additional configurations.
*/
export const Textblock = (blocks: TextblockTarget[], options?: TextblockOptions) => {
console.log(`[TB] Textblock v${TB_VERSION || "🤔"}`);

const { debounce = 200, debug = false } = options || ({} as TextblockOptions);

if (typeof window !== "undefined") {
Expand Down
9 changes: 8 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// JSON Schema: https://json.schemastore.org/webpack

const TerserPlugin = require("terser-webpack-plugin");
const { version } = require("./package.json");
const webpack = require("webpack");

module.exports = (env, argv) => {
return {
Expand All @@ -26,6 +28,11 @@ module.exports = (env, argv) => {
output: {
filename: "textblock.min.js",
path: __dirname + "/dist"
}
},
plugins: [
new webpack.DefinePlugin({
TB_VERSION: JSON.stringify(version)
})
]
};
};

0 comments on commit f5c583e

Please sign in to comment.