From c85cb4365d66c809a67c816eb945d9d13826e6c6 Mon Sep 17 00:00:00 2001 From: Bradley Matusiak Date: Tue, 24 May 2022 17:08:18 -0400 Subject: [PATCH] webpack example (#1240) --- examples/webpack/.gitignore | 3 +++ examples/webpack/package.json | 17 +++++++++++++++ examples/webpack/src/app.js | 9 ++++++++ examples/webpack/src/index.html | 5 +++++ examples/webpack/webpack.config.js | 35 ++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 examples/webpack/.gitignore create mode 100644 examples/webpack/package.json create mode 100644 examples/webpack/src/app.js create mode 100644 examples/webpack/src/index.html create mode 100644 examples/webpack/webpack.config.js diff --git a/examples/webpack/.gitignore b/examples/webpack/.gitignore new file mode 100644 index 00000000..5fa4b4f8 --- /dev/null +++ b/examples/webpack/.gitignore @@ -0,0 +1,3 @@ +package-lock.json +node_modules +public \ No newline at end of file diff --git a/examples/webpack/package.json b/examples/webpack/package.json new file mode 100644 index 00000000..33d82a22 --- /dev/null +++ b/examples/webpack/package.json @@ -0,0 +1,17 @@ +{ + "name": "webpack", + "version": "1.0.0", + "description": "webpack build example", + "scripts": { + "build": "webpack --devtool source-map --config webpack.config.js", + "prepare": "npm run build" + }, + "author": "", + "license": "ISC", + "dependencies": { + "gun": "github:amark/gun", + "html-webpack-plugin": "^5.5.0", + "webpack": "^5.72.1", + "webpack-cli": "^4.9.2" + } +} diff --git a/examples/webpack/src/app.js b/examples/webpack/src/app.js new file mode 100644 index 00000000..96dd4e67 --- /dev/null +++ b/examples/webpack/src/app.js @@ -0,0 +1,9 @@ +define(function(require, exports, module) { + + var Gun = require("gun"); + + var gun = new Gun(); + + gun.get("hello").get("world").put("from gun").on((data, key) => console.log(data, key)); + +}); \ No newline at end of file diff --git a/examples/webpack/src/index.html b/examples/webpack/src/index.html new file mode 100644 index 00000000..3304ff12 --- /dev/null +++ b/examples/webpack/src/index.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/webpack/webpack.config.js b/examples/webpack/webpack.config.js new file mode 100644 index 00000000..86300869 --- /dev/null +++ b/examples/webpack/webpack.config.js @@ -0,0 +1,35 @@ +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +let plugins = []; + +plugins.push(new HtmlWebpackPlugin({ + filename: './index.html', + template: './src/index.html', + inject: true, + minify: false, + hash: false, + cache: false, + showErrors: false +})); + +console.log("webpack config loaded"); + +module.exports = { + + mode: "development", + + // stats: 'minimal', + stats: 'normal', + // stats: 'verbose', + + entry: [path.resolve(__dirname, './src/app.js')], + + output: { + path: path.resolve(__dirname, './public'), + clean: true, + filename: './app.js' + }, + + plugins: plugins +};