commit 9ca77d23a715e1c0e38e5095930f5395c876da9f
parent b1a31050949f8eb24d70b7f8e915b71432525b0b
Author: Marcel <mtrnord1@gmail.com>
Date: Sat, 11 Jul 2020 13:38:22 +0200
Try to fix netlify builds by ensuring the wasm file is present when doing the worker task
Took 12 minutes
Diffstat:
5 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="JavaScriptLibraryMappings">
+ <file url="file://$PROJECT_DIR$" libraries="{Node.js Core}" />
+ </component>
+</project>
+\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
@@ -873,6 +873,12 @@
"tweetnacl": "^0.14.3"
}
},
+ "before-build-webpack": {
+ "version": "0.2.9",
+ "resolved": "https://registry.npmjs.org/before-build-webpack/-/before-build-webpack-0.2.9.tgz",
+ "integrity": "sha512-zhRNAqPATAx0ojj/0LaKyQRjU/6tTMw5JEu2XGYKCzg94istvI1Mk7nOMH2+8cDXLPCgEugBVjGa/YEG0kvHcA==",
+ "dev": true
+ },
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
diff --git a/package.json b/package.json
@@ -13,6 +13,7 @@
},
"devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^1.3.1",
+ "before-build-webpack": "^0.2.9",
"copy-webpack-plugin": "^6.0.3",
"cross-env": "^7.0.2",
"css-loader": "^3.6.0",
diff --git a/startup_helper/WaitPlugin.js b/startup_helper/WaitPlugin.js
@@ -0,0 +1,24 @@
+const WebpackBeforeBuildPlugin = require('before-build-webpack')
+const fs = require('fs')
+
+class WaitPlugin extends WebpackBeforeBuildPlugin {
+ constructor(file, interval = 100, timeout = 10000) {
+ super(function(stats, callback) {
+ let start = Date.now()
+
+ function poll() {
+ if (fs.existsSync(file)) {
+ callback()
+ } else if (Date.now() - start > timeout) {
+ throw Error("Maybe it just wasn't meant to be.")
+ } else {
+ setTimeout(poll, interval)
+ }
+ }
+
+ poll()
+ })
+ }
+}
+
+module.exports = WaitPlugin
diff --git a/webpack.config.js b/webpack.config.js
@@ -4,6 +4,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
+const WaitPlugin = require('./startup_helper/WaitPlugin');
const distPath = path.resolve(__dirname, "dist");
const appConfig = (env, argv) => {
@@ -89,7 +90,9 @@ const appConfig = (env, argv) => {
const workerConfig = {
entry: "./startup_helper/worker/worker.js",
target: "webworker",
- plugins: [],
+ plugins: [
+ new WaitPlugin('./dist/daydream.wasm', 100, 480000)
+ ],
resolve: {
extensions: [".js", ".wasm"]
},