soiz1 commited on
Commit
6513f54
·
verified ·
1 Parent(s): 98060fc

Update webpack.config.js

Browse files
Files changed (1) hide show
  1. webpack.config.js +37 -10
webpack.config.js CHANGED
@@ -1,15 +1,13 @@
1
  const defaultsDeep = require('lodash.defaultsdeep');
2
  var path = require('path');
3
  var webpack = require('webpack');
 
4
 
5
  // Plugins
6
  var CopyWebpackPlugin = require('copy-webpack-plugin');
7
  var HtmlWebpackPlugin = require('html-webpack-plugin');
8
  var TWGenerateServiceWorkerPlugin = require('./src/playground/generate-service-worker-plugin');
9
  var defaultsdeep = require('lodash.defaultsdeep');
10
- //var GhPagesWebpackPlugin = require('gh-pages-webpack-plugin');
11
-
12
-
13
 
14
  // PostCss
15
  var autoprefixer = require('autoprefixer');
@@ -28,6 +26,33 @@ const htmlWebpackPluginCommon = {
28
  meta: JSON.parse(process.env.EXTRA_META || '{}')
29
  };
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  const base = {
32
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
33
  devtool: process.env.SOURCEMAP ? process.env.SOURCEMAP : process.env.NODE_ENV === 'production' ? false : 'cheap-module-source-map',
@@ -119,6 +144,8 @@ const base = {
119
  if (!process.env.CI) {
120
  base.plugins.push(new webpack.ProgressPlugin());
121
  }
 
 
122
 
123
  module.exports = [
124
  // to run editor examples
@@ -167,35 +194,35 @@ module.exports = [
167
  chunks: ['editor'],
168
  template: 'src/playground/index.ejs',
169
  filename: 'editor.html',
170
- title: 'PenguinMod - Editor',
171
  ...htmlWebpackPluginCommon
172
  }),
173
  new HtmlWebpackPlugin({
174
  chunks: ['playground'],
175
  template: 'src/playground/index.ejs',
176
  filename: 'playground.html',
177
- title: 'PenguinMod - Playground',
178
  ...htmlWebpackPluginCommon
179
  }),
180
  new HtmlWebpackPlugin({
181
  chunks: ['player'],
182
  template: 'src/playground/index.ejs',
183
  filename: 'index.html',
184
- title: 'PenguinMod - A mod of TurboWarp',
185
  ...htmlWebpackPluginCommon
186
  }),
187
  new HtmlWebpackPlugin({
188
  chunks: ['fullscreen'],
189
  template: 'src/playground/index.ejs',
190
  filename: 'fullscreen.html',
191
- title: 'PenguinMod - A mod of TurboWarp',
192
  ...htmlWebpackPluginCommon
193
  }),
194
  new HtmlWebpackPlugin({
195
  chunks: ['embed'],
196
  template: 'src/playground/index.ejs',
197
  filename: 'embed.html',
198
- title: 'Embedded Project - PenguinMod',
199
  noTheme: true,
200
  ...htmlWebpackPluginCommon
201
  }),
@@ -203,14 +230,14 @@ module.exports = [
203
  chunks: ['addon-settings'],
204
  template: 'src/playground/simple.ejs',
205
  filename: 'addons.html',
206
- title: 'Addon Settings - PenguinMod',
207
  ...htmlWebpackPluginCommon
208
  }),
209
  new HtmlWebpackPlugin({
210
  chunks: ['credits'],
211
  template: 'src/playground/simple.ejs',
212
  filename: 'credits.html',
213
- title: 'PenguinMod & TurboWarp Credits',
214
  noSplash: true,
215
  ...htmlWebpackPluginCommon
216
  }),
 
1
  const defaultsDeep = require('lodash.defaultsdeep');
2
  var path = require('path');
3
  var webpack = require('webpack');
4
+ const { exec } = require('child_process');
5
 
6
  // Plugins
7
  var CopyWebpackPlugin = require('copy-webpack-plugin');
8
  var HtmlWebpackPlugin = require('html-webpack-plugin');
9
  var TWGenerateServiceWorkerPlugin = require('./src/playground/generate-service-worker-plugin');
10
  var defaultsdeep = require('lodash.defaultsdeep');
 
 
 
11
 
12
  // PostCss
13
  var autoprefixer = require('autoprefixer');
 
26
  meta: JSON.parse(process.env.EXTRA_META || '{}')
27
  };
28
 
29
+ class UploadAfterBuildPlugin {
30
+ apply(compiler) {
31
+ compiler.hooks.done.tap('UploadAfterBuildPlugin', (stats) => {
32
+ console.log('🔄 ビルド完了、upload.sh を実行中...');
33
+ exec('./upload.sh', (err, stdout, stderr) => {
34
+ if (stdout) {
35
+ console.log('📤 upload.sh 出力:\n', stdout);
36
+ }
37
+
38
+ if (stderr) {
39
+ console.error('⚠️ upload.sh スクリプト stderr:\n', stderr);
40
+ }
41
+
42
+ if (err) {
43
+ console.error('❌ upload.sh の実行エラー:');
44
+ console.error('コード:', err.code);
45
+ console.error('シグナル:', err.signal);
46
+ console.error('エラー情報:', err);
47
+ // process.exit(1); // ビルド失敗として扱いたい場合はこれを有効に
48
+ } else {
49
+ console.log('✅ upload.sh 実行完了');
50
+ }
51
+ });
52
+ });
53
+ }
54
+ }
55
+
56
  const base = {
57
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
58
  devtool: process.env.SOURCEMAP ? process.env.SOURCEMAP : process.env.NODE_ENV === 'production' ? false : 'cheap-module-source-map',
 
144
  if (!process.env.CI) {
145
  base.plugins.push(new webpack.ProgressPlugin());
146
  }
147
+ // WebpackShellPluginNext の代わりにカスタムプラグインを追加
148
+ base.plugins.push(new UploadAfterBuildPlugin());
149
 
150
  module.exports = [
151
  // to run editor examples
 
194
  chunks: ['editor'],
195
  template: 'src/playground/index.ejs',
196
  filename: 'editor.html',
197
+ title: '学校用スクラッチ - エディター',
198
  ...htmlWebpackPluginCommon
199
  }),
200
  new HtmlWebpackPlugin({
201
  chunks: ['playground'],
202
  template: 'src/playground/index.ejs',
203
  filename: 'playground.html',
204
+ title: '学校用スクラッチ - プレイグラウンド',
205
  ...htmlWebpackPluginCommon
206
  }),
207
  new HtmlWebpackPlugin({
208
  chunks: ['player'],
209
  template: 'src/playground/index.ejs',
210
  filename: 'index.html',
211
+ title: '学校用スクラッチ - A mod of Penguinmod',
212
  ...htmlWebpackPluginCommon
213
  }),
214
  new HtmlWebpackPlugin({
215
  chunks: ['fullscreen'],
216
  template: 'src/playground/index.ejs',
217
  filename: 'fullscreen.html',
218
+ title: '学校用スクラッチ - A mod of Penguinmod',
219
  ...htmlWebpackPluginCommon
220
  }),
221
  new HtmlWebpackPlugin({
222
  chunks: ['embed'],
223
  template: 'src/playground/index.ejs',
224
  filename: 'embed.html',
225
+ title: '埋め込みプロジェクト - 学校用スクラッチ',
226
  noTheme: true,
227
  ...htmlWebpackPluginCommon
228
  }),
 
230
  chunks: ['addon-settings'],
231
  template: 'src/playground/simple.ejs',
232
  filename: 'addons.html',
233
+ title: 'アドオン設定 - 学校用スクラッチ',
234
  ...htmlWebpackPluginCommon
235
  }),
236
  new HtmlWebpackPlugin({
237
  chunks: ['credits'],
238
  template: 'src/playground/simple.ejs',
239
  filename: 'credits.html',
240
+ title: 'ペンギンモッドとTurboWarpのクレジット',
241
  noSplash: true,
242
  ...htmlWebpackPluginCommon
243
  }),