Skip to content

Commit

Permalink
Reorganize build paths
Browse files Browse the repository at this point in the history
  • Loading branch information
p3zo committed Dec 26, 2022
1 parent 78fbf6c commit dfe5637
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
dist/
node_modules

.DS_Store
.idea
dist/
4 changes: 2 additions & 2 deletions src/main.js → src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function CreateLayerStack(video, width, height) {
async function Run() {
// Download hand tracking models
const modelFiles = await yoha.DownloadMultipleYohaTfjsModelBlobs(
'/box/model.json',
'/lan/model.json',
'box/model.json',
'lan/model.json',
(rec, total) => {
if (rec / total == 1) {
console.log('Loaded hand tracking model')
Expand Down
File renamed without changes.
File renamed without changes.
59 changes: 28 additions & 31 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ const TerserPlugin = require('terser-webpack-plugin');

const PRODUCTION = !!process.env.PRODUCTION;

const DEMOS = ['tfjs_webgl', 'tfjs_wasm'];

module.exports = (env) => {
const config = {
mode: PRODUCTION ? 'production' : 'development',
entry: {
main: './src/index.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
clean: true,
filename: 'bundle.js',
publicPath: '/',
},
devtool: 'inline-source-map',
devServer: {
headers: {
Expand All @@ -26,32 +33,9 @@ module.exports = (env) => {
},
watchFiles: ['src/**/*'],
},
output: {
path: path.resolve(__dirname, 'dist'),
clean: true,
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
...DEMOS.map((d) => new HtmlWebpackPlugin({
template: 'index.html',
filename: 'index.html',
})),
new CopyWebpackPlugin({
patterns: [
{from: 'node_modules/@tensorflow/tfjs-backend-wasm/dist/*.wasm'},
{from: 'node_modules/@handtracking.io/yoha/models/', to: './'},
{from: 'dist', to: './'},
]
})
],
optimization: {
minimizer: [new TerserPlugin({
extractComments: false,
exclude: /\.min\./,
})],
},
module: {
rules: [
{
Expand All @@ -70,12 +54,25 @@ module.exports = (env) => {
},
],
},
entry: {
example: {
import: './src/main.js',
filename: 'main.js',
},
}
plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
filename: 'index.html',
}),
new CopyWebpackPlugin({
patterns: [
{from: 'node_modules/@tensorflow/tfjs-backend-wasm/dist/*.wasm'},
{from: 'node_modules/@handtracking.io/yoha/models/', to: './'},
{from: 'static', to: './'},
]
})
],
optimization: {
minimizer: [new TerserPlugin({
extractComments: false,
exclude: /\.min\./,
})],
},
};

return [config];
Expand Down

0 comments on commit dfe5637

Please sign in to comment.