Skip to content

Commit 111d003

Browse files
committed
feat: github action for demo.
1 parent 4c93294 commit 111d003

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
uses: peaceiris/actions-gh-pages@v3
2929
with:
3030
github_token: ${{ secrets.ACTION }}
31-
publish_dir: dist/demo
31+
publish_dir: dist

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"start": "webpack serve",
1212
"build": "webpack --mode production",
13-
"build:demo": "webpack --config src/demo/webpack.demo.config.js --mode production",
13+
"build:demo": "webpack --config webpack.demo.config.js --mode production",
1414
"prepare": "npm run build"
1515
},
1616
"keywords": [

src/demo/demo.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@
77
</head>
88
<body>
99
<div id="tech-particles"></div>
10+
<script type="module">
11+
import { initWebGLTechParticles } from './<%= htmlWebpackPlugin.files.js[0] %>';
12+
initWebGLTechParticles('tech-particles');
13+
</script>
1014
</body>
1115
</html>

src/texture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const DEFAULT_ICONS = [
2626
'open-ai.webp',
2727
];
2828

29-
const DEFAULT_ICON_FOLDER = './dist/assets/icons';
29+
const DEFAULT_ICON_FOLDER = ICON_FOLDER;
3030

3131
const loadTexture = (textureLoader, path) => {
3232
return new Promise((resolve) => {

webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const path = require('path');
22
const CopyWebpackPlugin = require('copy-webpack-plugin');
33
const TerserPlugin = require('terser-webpack-plugin');
4+
const webpack = require('webpack');
45

56
module.exports = {
67
entry: './src/index.js',
@@ -55,5 +56,8 @@ module.exports = {
5556
{from: 'src/assets/icons', to: 'assets/icons'},
5657
],
5758
}),
59+
new webpack.DefinePlugin({
60+
ICON_FOLDER: JSON.stringify('./dist/assets/icons'),
61+
}),
5862
],
5963
};

src/demo/webpack.demo.config.js renamed to webpack.demo.config.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
const path = require('path');
22
const CopyWebpackPlugin = require('copy-webpack-plugin');
33
const HtmlWebpackPlugin = require('html-webpack-plugin');
4+
const webpack = require('webpack');
45

56
module.exports = {
6-
entry: './src/demo/demo.js', // Точка входа — demo.js
7+
entry: './src/demo/demo.js',
78
mode: 'production',
89
output: {
9-
filename: 'webgl-tech-particles.demo.js', // Имя выходного файла
10-
path: path.resolve(__dirname, '../../dist/demo'), // Выходная папка — dist/demo
11-
clean: true, // Очистка папки перед сборкой
10+
filename: 'webgl-tech-particles.demo.js',
11+
path: path.resolve(__dirname, 'dist'),
12+
library: {
13+
type: 'module',
14+
},
15+
clean: true,
16+
},
17+
experiments: {
18+
outputModule: true,
1219
},
1320
module: {
1421
rules: [
@@ -30,24 +37,27 @@ module.exports = {
3037
test: /\.(png|jpg|gif|webp)$/,
3138
type: 'asset/resource',
3239
generator: {
33-
filename: 'assets/icons/[name][ext]', // Иконки будут в assets/icons
40+
filename: 'assets/icons/[name][ext]',
3441
},
3542
},
3643
],
3744
},
3845
plugins: [
39-
// Копируем settings.json и иконки
4046
new CopyWebpackPlugin({
4147
patterns: [
42-
{ from: path.resolve(__dirname, '../../settings.json'), to: 'settings.json' },
43-
{ from: path.resolve(__dirname, '../assets/icons'), to: 'assets/icons' },
48+
{from: 'settings.json', to: 'settings.json'},
49+
{from: 'src/assets/icons', to: 'assets/icons'},
4450
],
4551
}),
46-
// Генерируем HTML-файл для демо
4752
new HtmlWebpackPlugin({
48-
template: path.resolve(__dirname, '../demo/demo.html'),
49-
filename: 'demo.html', // Имя выходного файла
50-
title: 'WebGL Tech Particles Demo', // Заголовок страницы
53+
template: 'src/demo/demo.html',
54+
filename: 'demo.html',
55+
title: 'WebGL Tech Particles Demo',
56+
inject: true,
57+
scriptLoading: 'module',
58+
}),
59+
new webpack.DefinePlugin({
60+
ICON_FOLDER: JSON.stringify('./assets/icons'),
5161
}),
5262
],
5363
};

0 commit comments

Comments
 (0)