From 04179b3e46f319e38bfd7d1ae127f826b9e753e3 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Sat, 14 Aug 2021 14:21:51 +0700 Subject: [PATCH] Spawn inklecate on build --- .gitignore | 1 + js/script.js | 2 +- package.json | 1 + pnpm-lock.yaml | 63 +++++++++++++++++++++++++++++++++++++++++++++++ webpack.config.js | 14 ++++++++++- 5 files changed, 79 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1407169..4586c86 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /node_modules /yarn.lock /package-lock.json +.ink.json diff --git a/js/script.js b/js/script.js index 4fc1888..2068436 100644 --- a/js/script.js +++ b/js/script.js @@ -1,6 +1,6 @@ import jQuery from 'jquery' const inkjs = require('inkjs').Story; -const entryPoint = 'fogg.ink.json'; +const entryPoint = 'game/fogg.ink.json'; let continueToNextChoice, displayText, loadGame, saveChoice, s; diff --git a/package.json b/package.json index 93e1122..7a6b8ad 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "copy-webpack-plugin": "^9.0.1", "cross-env": "^7.0.3", "css-loader": "^6.2.0", + "execa-webpack-plugin": "^6.0.2", "inkjs": "^2.0.0", "jquery": "^3.6.0", "mini-css-extract-plugin": "^2.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3db7db5..8f3f773 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,6 +10,7 @@ specifiers: copy-webpack-plugin: ^9.0.1 cross-env: ^7.0.3 css-loader: ^6.2.0 + execa-webpack-plugin: ^6.0.2 inkjs: ^2.0.0 jquery: ^3.6.0 mini-css-extract-plugin: ^2.2.0 @@ -29,6 +30,7 @@ devDependencies: copy-webpack-plugin: 9.0.1_webpack@5.50.0 cross-env: 7.0.3 css-loader: 6.2.0_webpack@5.50.0 + execa-webpack-plugin: 6.0.2_webpack@5.50.0 inkjs: 2.0.0 jquery: 3.6.0 mini-css-extract-plugin: 2.2.0_webpack@5.50.0 @@ -2032,6 +2034,12 @@ packages: engines: {node: '>= 0.8'} dev: true + /end-of-stream/1.4.4: + resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} + dependencies: + once: 1.4.0 + dev: true + /engine.io-client/3.5.2: resolution: {integrity: sha512-QEqIp+gJ/kMHeUun7f5Vv3bteRHppHH/FMBQX/esFj/fuYfjyUKWGMo3VCvIP/V8bE9KcjHmRZrhIz2Z9oNsDA==} dependencies: @@ -2158,6 +2166,32 @@ packages: engines: {node: '>=0.8.x'} dev: true + /execa-webpack-plugin/6.0.2_webpack@5.50.0: + resolution: {integrity: sha512-hpggPPTWIpUTWZ30YkEg7QVh1i3eXCP1c1p/2C8BvBxIks2HRGNZSrt7OsuOGVOIhfr9UusfS7+39LCh0wEJuQ==} + engines: {node: '>= 10.13.0'} + peerDependencies: + webpack: ^4.37.0 || ^5.0.0 + dependencies: + execa: 4.1.0 + p-limit: 2.3.0 + webpack: 5.50.0_webpack-cli@4.7.2 + dev: true + + /execa/4.1.0: + resolution: {integrity: sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==} + engines: {node: '>=10'} + dependencies: + cross-spawn: 7.0.3 + get-stream: 5.2.0 + human-signals: 1.1.1 + is-stream: 2.0.1 + merge-stream: 2.0.0 + npm-run-path: 4.0.1 + onetime: 5.1.2 + signal-exit: 3.0.3 + strip-final-newline: 2.0.0 + dev: true + /execa/5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -2297,6 +2331,13 @@ packages: has-symbols: 1.0.2 dev: true + /get-stream/5.2.0: + resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==} + engines: {node: '>=8'} + dependencies: + pump: 3.0.0 + dev: true + /get-stream/6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} @@ -2412,6 +2453,11 @@ packages: - debug dev: true + /human-signals/1.1.1: + resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} + engines: {node: '>=8.12.0'} + dev: true + /human-signals/2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} @@ -2828,6 +2874,12 @@ packages: ee-first: 1.1.1 dev: true + /once/1.4.0: + resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=} + dependencies: + wrappy: 1.0.2 + dev: true + /onetime/5.1.2: resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} engines: {node: '>=6'} @@ -3016,6 +3068,13 @@ packages: source-map-js: 0.6.2 dev: true + /pump/3.0.0: + resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} + dependencies: + end-of-stream: 1.4.4 + once: 1.4.0 + dev: true + /punycode/2.1.1: resolution: {integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==} engines: {node: '>=6'} @@ -3744,6 +3803,10 @@ packages: strip-ansi: 6.0.0 dev: true + /wrappy/1.0.2: + resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=} + dev: true + /ws/7.4.6: resolution: {integrity: sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==} engines: {node: '>=8.3.0'} diff --git a/webpack.config.js b/webpack.config.js index e591566..98106d5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,7 @@ const path = require('path') const MiniCssExtractPlugin = require('mini-css-extract-plugin') -const devMode = (process.env.NODE_ENV !== 'production') const CopyPlugin = require('copy-webpack-plugin'); +const ExecaPlugin = require("execa-webpack-plugin"); module.exports = { mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', @@ -11,9 +11,21 @@ module.exports = { ], plugins: [ new MiniCssExtractPlugin(), + new ExecaPlugin({ + onBeforeRun: [ + { + cmd: "inklecate", + args: ["game/fogg.ink"], + options: { + cwd: process.cwd() + } + } + ] + }), new CopyPlugin({ patterns: [ { from: './html/', to: '' }, + { from: './game/*.json', to: '' }, ], }), ],