diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000000000000000000000000000000000000..37565e32b4c975a1f04c29492681bd9d5e5deae4 --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +tsconfig.servers.buildinfo \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b50d0f80ee302c08a7b65bfc6250b8a1b27b799e..77db567828aaa3e147807aed27370485c39056e9 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/package.json b/package.json index 1f5cd7461437a8c200e6ee94b6bfa8eb2bb8f79d..1544195e5f1eb53fa3bc3a48983f1781985024f9 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,8 @@ "ts-jest": "^25.4.0", "typescript": "^3.8.3", "webpack": "^4.42.1", - "webpack-cli": "^3.3.11" + "webpack-cli": "^3.3.11", + "webpack-version-file-plugin": "^0.4.0" }, "dependencies": { "@material-ui/core": "^4.9.10", diff --git a/src/mol-plugin/version.ts b/src/mol-plugin/version.ts index 949807afaef319e2d8acf25d7b409b35275a317a..b42aab3e0344259fd70ce7d00e57f31f0a70af0f 100644 --- a/src/mol-plugin/version.ts +++ b/src/mol-plugin/version.ts @@ -5,11 +5,8 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -/** version from package.json, to be filled in at bundle build time */ -declare const __VERSION__: string; -export const PLUGIN_VERSION = __VERSION__; +/** version from package.json, to be filled in at build time */ +export const PLUGIN_VERSION = ''; -/** unix time stamp, to be filled in at bundle build time */ -declare const __VERSION_TIMESTAMP__: number; -export const PLUGIN_VERSION_TIMESTAMP = __VERSION_TIMESTAMP__; -export const PLUGIN_VERSION_DATE = new Date(PLUGIN_VERSION_TIMESTAMP); \ No newline at end of file +/** to be filled in at build time */ +export const PLUGIN_VERSION_DATE = +new Date(); \ No newline at end of file diff --git a/webpack.config.common.js b/webpack.config.common.js index 2365f4b865169d566f591efa979af9538a25915e..f062c5b85650410c96e66352dfb00e6661a3d1da 100644 --- a/webpack.config.common.js +++ b/webpack.config.common.js @@ -2,6 +2,7 @@ const path = require('path'); const webpack = require('webpack'); const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const VersionFile = require('webpack-version-file-plugin'); // const CircularDependencyPlugin = require('circular-dependency-plugin'); const sharedConfig = { @@ -38,11 +39,17 @@ const sharedConfig = { ], }), new webpack.DefinePlugin({ - __VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./package.json').version), true), - __VERSION_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true), + // __VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./package.json').version), true), + // __VERSION_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true), 'process.env.DEBUG': JSON.stringify(process.env.DEBUG) }), - new MiniCssExtractPlugin({ filename: 'app.css' }) + new MiniCssExtractPlugin({ filename: 'app.css' }), + new VersionFile({ + extras: { timestamp: `${new Date().valueOf()}` }, + packageFile: path.resolve(__dirname, 'package.json'), + templateString: `export const PLUGIN_VERSION = '<%= package.version %>';\nexport const PLUGIN_VERSION_DATE = new Date(<%= extras.timestamp %>);`, + outputFile: path.resolve(__dirname, 'lib/mol-plugin/version.js') + }) ], resolve: { modules: [