From afc8e7c628b2ee0582721ad3f790a9f190386f47 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 25 Jan 2021 21:02:17 -0600 Subject: [PATCH] include offline copy of docs This grabs the docs via the @pybricks/ide-docs package and copies them to the build directory with copy-webpack-plugin. The service worker automatically picks up these files for precache since they go through webpack. --- craco.config.js | 9 +++++++++ package.json | 2 ++ src/components/App.tsx | 2 +- src/service-worker.ts | 2 +- yarn.lock | 26 ++++++++++++++++++++++++-- 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/craco.config.js b/craco.config.js index 636eb660..0e03f0cf 100644 --- a/craco.config.js +++ b/craco.config.js @@ -8,6 +8,7 @@ const { getLoaders, loaderByName, } = require('@craco/craco'); +const CopyPlugin = require('copy-webpack-plugin'); const LicensePlugin = require('license-webpack-plugin').LicenseWebpackPlugin; const satisfies = require('spdx-satisfies'); @@ -187,6 +188,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`, module.exports = { webpack: { plugins: [ + new CopyPlugin({ + patterns: [ + { + from: 'node_modules/@pybricks/ide-docs/build/html', + to: 'static/docs', + }, + ], + }), new LicensePlugin({ outputFilename: 'static/oss-licenses.json', perChunkOutput: false, diff --git a/package.json b/package.json index 467cb191..c0f65bc0 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@blueprintjs/core": "^3.38.1", "@craco/craco": "^6.0.0", "@pybricks/firmware": "4.5.0", + "@pybricks/ide-docs": "1.0.0", "@pybricks/mpy-cross-v5": "^2.0.0", "@shopify/react-i18n": "^5.2.1", "@testing-library/dom": "^7.29.2", @@ -30,6 +31,7 @@ "@types/zen-push": "^0.1.1", "ace-builds": "^1.4.12", "babel-plugin-macros": "^3.0.1", + "copy-webpack-plugin": "6", "file-saver": "^2.0.5", "jszip": "^3.5.0", "license-webpack-plugin": "^2.3.11", diff --git a/src/components/App.tsx b/src/components/App.tsx index 04a15162..2a982ba1 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -52,7 +52,7 @@ function App(): JSX.Element {
{dragging &&
}