From 099f6d35502e4c6a62af3ef464b8ac9f243c8b62 Mon Sep 17 00:00:00 2001 From: Mizok Date: Mon, 18 Apr 2022 16:42:35 +0800 Subject: [PATCH] update --- package-lock.json | 31 +++++++++++++++++++ package.json | 3 +- .../examples/{demo.scss => demo/main.scss} | 2 +- src/ts/examples/{demo.ts => demo/main.ts} | 0 .../main.ts} | 0 .../main.ts} | 0 webpack.config.ts | 21 ++++++++++--- 7 files changed, 51 insertions(+), 6 deletions(-) rename src/scss/examples/{demo.scss => demo/main.scss} (96%) rename src/ts/examples/{demo.ts => demo/main.ts} (100%) rename src/ts/examples/{universe-alpha.ts => universe-alpha/main.ts} (100%) rename src/ts/examples/{universe-beta.ts => universe-beta/main.ts} (100%) diff --git a/package-lock.json b/package-lock.json index 1fa8857..ec7485c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6797,6 +6797,37 @@ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "dev": true }, + "shader-loader": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/shader-loader/-/shader-loader-1.3.1.tgz", + "integrity": "sha512-dt8F9K0x4rjmaFyHh7rNDfpt4LUiR64zhNIEwp2WbE99B3z4ALuvvmhftkElg93dUD6sTmv/aXa/z9SJiEddcA==", + "dev": true, + "requires": { + "loader-utils": "^1.1.0" + }, + "dependencies": { + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "loader-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", + "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^1.0.1" + } + } + } + }, "shallow-clone": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", diff --git a/package.json b/package.json index 7d6e1b3..dbf98f5 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "postcss-preset-env": "^6.7.0", "sass": "^1.33.0", "sass-loader": "^12.0.0", + "shader-loader": "^1.3.1", "style-loader": "^2.0.0", "template-ejs-loader": "latest", "terser-webpack-plugin": "^5.3.1", @@ -56,4 +57,4 @@ "> 1%", "IE 10" ] -} \ No newline at end of file +} diff --git a/src/scss/examples/demo.scss b/src/scss/examples/demo/main.scss similarity index 96% rename from src/scss/examples/demo.scss rename to src/scss/examples/demo/main.scss index 8ada72a..8b61f78 100644 --- a/src/scss/examples/demo.scss +++ b/src/scss/examples/demo/main.scss @@ -1,4 +1,4 @@ -@import '../util/main'; +@import '../../util/main'; .centered { display: flex; diff --git a/src/ts/examples/demo.ts b/src/ts/examples/demo/main.ts similarity index 100% rename from src/ts/examples/demo.ts rename to src/ts/examples/demo/main.ts diff --git a/src/ts/examples/universe-alpha.ts b/src/ts/examples/universe-alpha/main.ts similarity index 100% rename from src/ts/examples/universe-alpha.ts rename to src/ts/examples/universe-alpha/main.ts diff --git a/src/ts/examples/universe-beta.ts b/src/ts/examples/universe-beta/main.ts similarity index 100% rename from src/ts/examples/universe-beta.ts rename to src/ts/examples/universe-beta/main.ts diff --git a/webpack.config.ts b/webpack.config.ts index 0f7ab35..495ac6b 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -23,11 +23,14 @@ const getEntriesByParsingTemplateNames = (templatesFolderName, atRoot = true) => const entryDependency = atRoot ? entryName : `${templatesFolderName}/${entryName}` - let entryPath = resolve(__dirname, `src/ts/${entryDependency}.ts`); + let entryPath1 = resolve(__dirname, `src/ts/${entryDependency}.ts`); + let entryPath2 = resolve(__dirname, `src/ts/${entryDependency}/main.ts`); // entry stylesheet - let entryStyleSheetPath = resolve(__dirname, `./src/scss/${entryDependency}.scss`); - entryPath = fs.existsSync(entryPath) ? entryPath : undefined; - entryStyleSheetPath = fs.existsSync(entryStyleSheetPath) ? entryStyleSheetPath : undefined; + let entryStyleSheetPath1 = resolve(__dirname, `./src/scss/${entryDependency}.scss`); + let entryStyleSheetPath2 = resolve(__dirname, `./src/scss/${entryDependency}/main.scss`); + + const entryPath = fs.existsSync(entryPath1) ? entryPath1 : fs.existsSync(entryPath2)? entryPath2:undefined; + const entryStyleSheetPath = fs.existsSync(entryStyleSheetPath1) ? entryStyleSheetPath1 : fs.existsSync(entryStyleSheetPath2)? entryStyleSheetPath2: undefined; // import es6-promise and scss util automatically entryObj[entryName] = ['es6-promise/auto', entryPath, './src/scss/reset.scss', entryStyleSheetPath].filter(function (x: string | undefined) { @@ -133,6 +136,15 @@ const config = (env: any, argv: any): webpack.Configuration => { } ], }, + { + test: /\.(glsl|vert|frag)$/, + loader: 'shader-loader', + options: { + glsl: { + chunkPath: resolve("/glsl/chunks") + } + } + }, { test: /\.ejs$/, use: [ @@ -200,6 +212,7 @@ const config = (env: any, argv: any): webpack.Configuration => { ] }, resolve: { + extensions:['.ts','.tsx','.js','.jsx','json'], alias: { '@img': resolve(__dirname, './src/assets/images/'), '@font': resolve(__dirname, './src/assets/fonts/')