Remove explicit JavaScript to simplify build

This commit is contained in:
Florine W. Dekker 2021-09-02 01:05:49 +02:00
parent ddb8d71960
commit 5b450e72ea
Signed by: FWDekker
GPG Key ID: 78B3EAF58145AF25
6 changed files with 21 additions and 64 deletions

View File

@ -13,12 +13,12 @@ module.exports = grunt => {
}, },
focus: { focus: {
dev: { dev: {
include: ["html", "js"], include: ["html"],
}, },
}, },
replace: { replace: {
dev: { dev: {
src: ["./dist/**/*.html", "./dist/**/*.js"], src: ["./dist/**/*.html"],
replacements: [ replacements: [
{ {
from: "%%VERSION_NUMBER%%", from: "%%VERSION_NUMBER%%",
@ -28,7 +28,7 @@ module.exports = grunt => {
overwrite: true overwrite: true
}, },
deploy: { deploy: {
src: ["./dist/*.html", "./dist/*.js"], src: ["./dist/*.html"],
replacements: [ replacements: [
{ {
from: "%%VERSION_NUMBER%%", from: "%%VERSION_NUMBER%%",
@ -43,37 +43,6 @@ module.exports = grunt => {
files: ["src/main/**/*.html"], files: ["src/main/**/*.html"],
tasks: ["copy:html", "replace:dev"], tasks: ["copy:html", "replace:dev"],
}, },
js: {
files: ["src/main/**/*.js"],
tasks: ["webpack:dev", "replace:dev"],
},
},
webpack: {
options: {
entry: "./src/main/js/main.js",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".js"],
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist/"),
},
},
dev: {
mode: "development",
devtool: "inline-source-map",
},
deploy: {
mode: "production",
},
}, },
}); });
@ -82,15 +51,13 @@ module.exports = grunt => {
grunt.loadNpmTasks("grunt-contrib-watch"); grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-focus"); grunt.loadNpmTasks("grunt-focus");
grunt.loadNpmTasks("grunt-text-replace"); grunt.loadNpmTasks("grunt-text-replace");
grunt.loadNpmTasks("grunt-webpack");
grunt.registerTask("dev", [ grunt.registerTask("dev", [
// Pre // Pre
"clean", "clean",
// Copy files // Copy files
"copy:html", "copy:html",
// Compile TS // Insert version number
"webpack:dev",
"replace:dev", "replace:dev",
]); ]);
grunt.registerTask("dev:server", ["dev", "focus:dev"]); grunt.registerTask("dev:server", ["dev", "focus:dev"]);
@ -99,8 +66,7 @@ module.exports = grunt => {
"clean", "clean",
// Copy files // Copy files
"copy:html", "copy:html",
// Compile TS // Insert version number
"webpack:deploy",
"replace:deploy", "replace:deploy",
]); ]);

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020 Felix W. Dekker Copyright (c) 2020 F.W. Dekker
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,8 +1,8 @@
{ {
"name": "privacy-policy", "name": "privacy-policy",
"version": "1.4.0", "version": "1.4.1",
"description": "The privacy policy of my website", "description": "The privacy policy of my website",
"author": "Felix W. Dekker", "author": "F.W. Dekker",
"browser": "dist/bundle.js", "browser": "dist/bundle.js",
"repository": { "repository": {
"type": "git", "type": "git",
@ -16,15 +16,12 @@
"deploy": "grunt deploy" "deploy": "grunt deploy"
}, },
"devDependencies": { "devDependencies": {
"grunt": "^1.4.0", "grunt": "^1.4.1",
"grunt-cli": "^1.4.2", "grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.0", "grunt-contrib-clean": "^2.0.0",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0", "grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0", "grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0", "grunt-text-replace": "^0.4.0"
"grunt-webpack": "^4.0.2",
"webpack": "^5.36.0",
"webpack-cli": "^4.6.0"
} }
} }

View File

@ -3,11 +3,20 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="Felix W. Dekker" /> <meta name="author" content="F.W. Dekker" />
<meta name="application-name" content="Privacy policy" /> <meta name="application-name" content="Privacy policy" />
<meta name="description" content="The privacy policy of my website." /> <meta name="description" content="The privacy policy of my website." />
<meta name="theme-color" content="#0033cc" /> <meta name="theme-color" content="#0033cc" />
<meta name="fwd:nav:target" content="#nav" />
<meta name="fwd:nav:highlight-path" content="/Privacy/" />
<meta name="fwd:header:target" content="#header" />
<meta name="fwd:header:title" content="Privacy policy" />
<meta name="fwd:footer:target" content="#footer" />
<meta name="fwd:footer:vcs-url" content="https://git.fwdekker.com/FWDekker/privacy-policy/" />
<meta name="fwd:footer:version" content="v%%VERSION_NUMBER%%" />
<meta name="fwd:footer:privacy-policy-url" />
<title>Privacy policy | FWDekker</title> <title>Privacy policy | FWDekker</title>
<link rel="stylesheet" href="https://static.fwdekker.com/fonts/roboto/roboto.css" /> <link rel="stylesheet" href="https://static.fwdekker.com/fonts/roboto/roboto.css" />
@ -112,7 +121,5 @@
</main> </main>
<script src="https://static.fwdekker.com/lib/template/2.x.x/template.js"></script> <script src="https://static.fwdekker.com/lib/template/2.x.x/template.js"></script>
<!--suppress HtmlUnknownTarget -->
<script src="bundle.js?v=%%VERSION_NUMBER%%"></script>
</body> </body>
</html> </html>

View File

@ -1,13 +0,0 @@
// noinspection JSUnresolvedVariable
const {$, doAfterLoad, footer, header, nav} = window.fwdekker;
doAfterLoad(() => {
$("#nav").appendChild(nav("/Privacy/"));
$("#header").appendChild(header({title: "Privacy policy"}));
$("#footer").appendChild(footer({
vcsURL: "https://git.fwdekker.com/FWDekker/privacy-policy/",
version: "v%%VERSION_NUMBER%%",
privacyPolicyURL: null
}));
});