diff --git a/package-lock.json b/package-lock.json index e787beac..aa53ff87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9439,6 +9439,12 @@ "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", "dev": true }, + "event-hooks-webpack-plugin": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/event-hooks-webpack-plugin/-/event-hooks-webpack-plugin-2.2.0.tgz", + "integrity": "sha512-r3j2Zez2Y8dRtSFCdNzmkN1m3p651a3VHi5A77zbhAP0Y08YTQaNx6vadCVaZ/szup9uBrVRlvUVgOW6pSINgg==", + "dev": true + }, "event-stream": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", diff --git a/package.json b/package.json index fca6766b..5810e43e 100755 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "unpack": "**/.webpack/main/*.worker.*" }, "extraResource": [ - "node_modules/@tiddlygit/tiddlywiki", + ".webpack/node_modules", "localization", "template/wiki", "build-resources/menubar@2x.png", @@ -160,6 +160,7 @@ "@types/electron-window-state": "5.0.0", "@types/eslint": "7.2.12", "@types/eslint-plugin-prettier": "3.1.0", + "@types/event-hooks-webpack-plugin": "^2.2.1", "@types/file-loader": "5.0.0", "@types/fs-extra": "9.0.11", "@types/i18next-fs-backend": "1.0.0", @@ -207,6 +208,7 @@ "eslint-plugin-security": "1.4.0", "eslint-plugin-security-node": "1.0.14", "eslint-plugin-unicorn": "32.0.1", + "event-hooks-webpack-plugin": "^2.2.0", "file-loader": "6.2.0", "fork-ts-checker-webpack-plugin": "6.2.10", "graphql-hooks": "5.1.2", diff --git a/webpack.plugins.js b/webpack.plugins.js index 92e63483..b694f034 100644 --- a/webpack.plugins.js +++ b/webpack.plugins.js @@ -4,17 +4,27 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin'); const CircularDependencyPlugin = require('circular-dependency-plugin'); const path = require('path'); +const fs = require('fs-extra'); const webpack = require('webpack'); const CopyPlugin = require('copy-webpack-plugin'); const ThreadsPlugin = require('threads-plugin'); const ExternalsPlugin = require('webpack5-externals-plugin'); +const EventHooksPlugin = require('event-hooks-webpack-plugin'); exports.main = [ // we only need one instance of TsChecker, it will check main and renderer all together new ForkTsCheckerWebpackPlugin(), new CopyPlugin({ // to is relative to ./.webpack/main/ - patterns: [{ from: 'localization', to: 'localization' }], + patterns: [ + { from: 'localization', to: 'localization' }, + ], + }), + new EventHooksPlugin({ + 'afterEmit': (compilation, done) => { + console.log('Copying tiddlywiki dependency to dist'); + void fs.copy('node_modules/@tiddlygit/tiddlywiki', './.webpack/node_modules/@tiddlygit/tiddlywiki', done); + }, }), new CircularDependencyPlugin({ // exclude detection of files based on a RegExp