diff --git a/webpack/loaders/git-loader.js b/webpack/loaders/git-loader.js deleted file mode 100644 index 5f003ffeca..0000000000 Binary files a/webpack/loaders/git-loader.js and /dev/null differ diff --git a/webpack/loaders/git-loader.ts b/webpack/loaders/git-loader.ts new file mode 100644 index 0000000000..51530b704e --- /dev/null +++ b/webpack/loaders/git-loader.ts @@ -0,0 +1,14 @@ +import { resolve } from 'path'; + +import { LoaderContext } from 'webpack'; + +/** + * Forces recompile whenever the current commit changes. + * Useful for generating the version hash in the UI. + */ +function loader(this: LoaderContext<{}>, content: string) { + this.addDependency(resolve(__dirname, '../../.git/logs/HEAD')); + this.callback(undefined, content); +} + +export default loader; \ No newline at end of file diff --git a/webpack/rules/git-refresh.ts b/webpack/rules/git-refresh.ts index aa16c5bcbd..2633eaded1 100644 --- a/webpack/rules/git-refresh.ts +++ b/webpack/rules/git-refresh.ts @@ -6,7 +6,7 @@ import type { RuleSetRule } from 'webpack'; const rule: RuleSetRule = { test: resolve(__dirname, '../../app/soapbox/utils/code.js'), use: { - loader: resolve(__dirname, '../loaders/git-loader.js'), + loader: resolve(__dirname, '../loaders/git-loader.ts'), }, };