commit 40302d8cb94a248655ac4967b73defeab0ce6726 Author: Stefano Pigozzi Date: Mon Jun 29 17:19:49 2020 +0200 First commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8923d61 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +build/* linguist-vendored +docs/* linguist-vendored diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..99b3528 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +/*.log +.idea/ diff --git a/.sentryclirc b/.sentryclirc new file mode 100644 index 0000000..5c9df79 --- /dev/null +++ b/.sentryclirc @@ -0,0 +1,3 @@ +[defaults] +org=stefano-pigozzi +project=example diff --git a/README.md b/README.md new file mode 100644 index 0000000..770ca72 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# [`bluelib-app-template`](https://github.com/Steffo99/bluelib-app-template) + +A [Preact](https://preactjs.com/) website template. diff --git a/package.json b/package.json new file mode 100644 index 0000000..a047228 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "private": true, + "name": "example", + "version": "0.1.0", + "license": "AGPL-3.0-or-later", + "scripts": { + "start": "preact watch --template src/template.html", + "build": "preact build --template src/template.html --no-prerender --dest docs && git add docs", + "ghpages": "npm run -s build && git add . && cross-env-shell git commit -m \"$npm_package_version\" && git push && cross-env-shell hub release create -m \"$npm_package_version\" \"$npm_package_version\" && cross-env-shell sentry-cli releases set-commits \"$npm_package_version\" --auto && cross-env-shell sentry-cli releases deploys \"$npm_package_version\" new --env production -n \"gh-pages\"" + }, + "devDependencies": { + "@sentry/webpack-plugin": "^1.11.1", + "cross-env": "^7.0.2", + "preact-cli": "^3.0.0-rc.14" + }, + "dependencies": { + "@fortawesome/fontawesome-svg-core": "^1.2.28", + "@fortawesome/free-brands-svg-icons": "^5.13.0", + "@fortawesome/free-regular-svg-icons": "^5.13.0", + "@fortawesome/free-solid-svg-icons": "^5.13.0", + "@fortawesome/react-fontawesome": "^0.1.9", + "@sentry/browser": "^5.15.5", + "@sentry/integrations": "^5.15.5", + "bluelib": "^0.13.14", + "css-loader": "^3.5.2", + "file-loader": "^5.1.0", + "history": "^4.10.1", + "less": "^3.10.3", + "less-loader": "^5.0.0", + "path-browserify": "^1.0.1", + "preact": "^10.4.0", + "preact-render-to-string": "^5.1.6", + "preact-router": "^3.2.1", + "process": "^0.11.10", + "react-chartjs-2": "^2.9.0", + "react-markdown": "^4.3.1", + "react-simplemde-editor": "^4.1.0", + "style-loader": "^1.1.4" + } +} diff --git a/preact.config.js b/preact.config.js new file mode 100644 index 0000000..91d0041 --- /dev/null +++ b/preact.config.js @@ -0,0 +1,60 @@ +import SentryCliPlugin from "@sentry/webpack-plugin"; +const DefinePlugin = require("webpack/lib/DefinePlugin"); +const ProvidePlugin = require("webpack/lib/ProvidePlugin"); + + +export default function (config, env, helpers) { + // noinspection JSUnresolvedVariable + config.resolve.alias["react"] = "preact/compat"; + // noinspection JSUnresolvedVariable + config.resolve.alias["react-dom"] = "preact/compat"; + // noinspection JSUnresolvedVariable + config.resolve.alias["path"] = "path-browserify"; + + config.module.rules.push( + { + test: /\.nojekyll$/, + loader: 'file-loader', + options: { + name: '.nojekyll' + } + } + ); + config.module.rules.push( + { + test: /CNAME$/, + loader: 'file-loader', + options: { + name: 'CNAME' + } + } + ); + config.module.rules.push( + { + test: /favicon\.ico$/, + loader: 'file-loader', + options: { + name: 'favicon.ico' + } + } + ); + + config.plugins.push( + new DefinePlugin({"process.env.RELEASE": `"${process.env.npm_package_version}"`}) + ); + + config.plugins.push( + new ProvidePlugin({"process": "process/browser"}) + ); + + if(env.production) { + config.plugins.push( + new SentryCliPlugin({ + include: './docs', + ignoreFile: ".gitignore", + configFile: '.sentryclirc', + release: process.env.npm_package_version, + }) + ) + } +}; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..6e3e84d --- /dev/null +++ b/src/index.js @@ -0,0 +1,46 @@ +// Import debugging tools +let Sentry = null; +if(process.env.NODE_ENV === "development") { + console.debug("Initializing Preact Debugger...") + require("preact/debug"); +} +else if(process.env.NODE_ENV === "production") { + console.debug("Initializing Sentry...") + Sentry = require("@sentry/browser"); + let SentryIntegrations = require("@sentry/integrations") + // noinspection JSUnresolvedVariable + Sentry.init({ + // TODO: Sentry DSN goes here + dsn: "", + release: process.env.RELEASE, + environment: "production", + beforeSend(event, hint) { + if (event.exception) { + Sentry.showReportDialog({ eventId: event.event_id }); + } + return event; + } + }); +} + +// noinspection ES6UnusedImports +import "bluelib/dist/index.css"; +import {theme} from "bluelib"; +import './meta/manifest.json'; +import './meta/CNAME'; +import './meta/.nojekyll'; +import './meta/favicon.ico'; + +import Router from 'preact-router'; +import {createHashHistory} from "history"; + +// noinspection JSUnusedGlobalSymbols +export default function(props) { + return ( +
+ + + +
+ ); +} diff --git a/src/meta/.nojekyll b/src/meta/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/src/meta/CNAME b/src/meta/CNAME new file mode 100644 index 0000000..5778335 --- /dev/null +++ b/src/meta/CNAME @@ -0,0 +1 @@ +example.org diff --git a/src/meta/favicon.ico b/src/meta/favicon.ico new file mode 100644 index 0000000..97a51c3 Binary files /dev/null and b/src/meta/favicon.ico differ diff --git a/src/meta/manifest.json b/src/meta/manifest.json new file mode 100644 index 0000000..f4bfa2d --- /dev/null +++ b/src/meta/manifest.json @@ -0,0 +1,16 @@ +{ + "name": "Example", + "short_name": "Example", + "start_url": "/", + "display": "browser", + "orientation": "portrait", + "background_color": "#0d193b", + "theme_color": "#1c2b4f", + "icons": [ + { + "src": "/favicon.ico", + "type": "image/x-icon", + "sizes": "800x800" + } + ] +} diff --git a/src/template.html b/src/template.html new file mode 100644 index 0000000..6573246 --- /dev/null +++ b/src/template.html @@ -0,0 +1,19 @@ + + + + + <% preact.title %> + + + + + <% preact.headEnd %> + + + <% preact.bodyEnd %> + +