Skip to content
Snippets Groups Projects
Commit 0704db23 authored by dsehnal's avatar dsehnal
Browse files

replace webpack-version-file-plugin

parent 425dca46
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -123,8 +123,7 @@ ...@@ -123,8 +123,7 @@
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"typescript": "^4.5.2", "typescript": "^4.5.2",
"webpack": "^5.64.1", "webpack": "^5.64.1",
"webpack-cli": "^4.8.0", "webpack-cli": "^4.9.1"
"webpack-version-file-plugin": "^0.4.0"
}, },
"dependencies": { "dependencies": {
"@types/argparse": "^2.0.10", "@types/argparse": "^2.0.10",
......
const path = require('path'); const path = require('path');
const fs = require('fs');
const webpack = require('webpack'); const webpack = require('webpack');
const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin'); const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const VersionFile = require('webpack-version-file-plugin'); const VERSION = require('./package.json').version;
class VersionFilePlugin {
apply() {
fs.writeFileSync(
path.resolve(__dirname, 'lib/mol-plugin/version.js'),
`export var PLUGIN_VERSION = '${VERSION}';\nexport var PLUGIN_VERSION_DATE = new Date(typeof __MOLSTAR_DEBUG_TIMESTAMP__ !== 'undefined' ? __MOLSTAR_DEBUG_TIMESTAMP__ : ${new Date().valueOf()});`);
}
}
const sharedConfig = { const sharedConfig = {
module: { module: {
...@@ -36,12 +45,7 @@ const sharedConfig = { ...@@ -36,12 +45,7 @@ const sharedConfig = {
'__MOLSTAR_DEBUG_TIMESTAMP__': webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true) '__MOLSTAR_DEBUG_TIMESTAMP__': webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true)
}), }),
new MiniCssExtractPlugin({ filename: 'molstar.css' }), new MiniCssExtractPlugin({ filename: 'molstar.css' }),
new VersionFile({ new VersionFilePlugin(),
extras: { timestamp: `${new Date().valueOf()}` },
packageFile: path.resolve(__dirname, 'package.json'),
templateString: `export var PLUGIN_VERSION = '<%= package.version %>';\nexport var PLUGIN_VERSION_DATE = new Date(typeof __MOLSTAR_DEBUG_TIMESTAMP__ !== 'undefined' ? __MOLSTAR_DEBUG_TIMESTAMP__ : <%= extras.timestamp %>);`,
outputFile: path.resolve(__dirname, 'lib/mol-plugin/version.js')
})
], ],
resolve: { resolve: {
modules: [ modules: [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment