forked from tools/josh
1
0
Fork 0

Add watcher for better builds

Fixes #137.
This commit is contained in:
Florine W. Dekker 2020-09-30 15:00:57 +02:00
parent 6901f5a02c
commit 41ca799eba
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
4 changed files with 37 additions and 6 deletions

View File

@ -7,18 +7,23 @@ module.exports = grunt => {
default: [".nyc_output/", "dist/"] default: [".nyc_output/", "dist/"]
}, },
copy: { copy: {
images: { css: {
files: [{expand: true, cwd: "src/main/", src: ["**/*.png", "**/*.ico"], dest: "dist/"}] files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "dist/"}]
}, },
html: { html: {
files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "dist/"}] files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "dist/"}]
}, },
css: { images: {
files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "dist/"}] files: [{expand: true, cwd: "src/main/", src: ["**/*.png", "**/*.ico"], dest: "dist/"}]
}, },
pwa: { pwa: {
files: [{expand: true, cwd: "src/main/", src: ["manifest.json", "sw.js"], dest: "dist/"}] files: [{expand: true, cwd: "src/main/", src: ["manifest.json", "sw.js"], dest: "dist/"}]
} },
},
focus: {
dev: {
include: ["css", "html", "link", "ts"],
},
}, },
replace: { replace: {
dev: { dev: {
@ -42,6 +47,24 @@ module.exports = grunt => {
overwrite: true overwrite: true
} }
}, },
watch: {
css: {
files: ["src/main/**/*.css"],
tasks: ["copy:css"],
},
html: {
files: ["src/main/**/*.html"],
tasks: ["copy:html"],
},
link: {
files: ["node_modules/@fwdekker/*/dist/**"],
tasks: ["webpack:dev", "replace:dev"],
},
ts: {
files: ["src/main/**/*.ts"],
tasks: ["webpack:dev", "replace:dev"],
},
},
webpack: { webpack: {
options: { options: {
entry: "./src/main/js/Main.ts", entry: "./src/main/js/Main.ts",
@ -74,6 +97,8 @@ module.exports = grunt => {
grunt.loadNpmTasks("grunt-contrib-clean"); grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy"); grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-focus");
grunt.loadNpmTasks("grunt-text-replace"); grunt.loadNpmTasks("grunt-text-replace");
grunt.loadNpmTasks("grunt-webpack"); grunt.loadNpmTasks("grunt-webpack");
@ -90,6 +115,7 @@ module.exports = grunt => {
// Post // Post
"replace:dev" "replace:dev"
]); ]);
grunt.registerTask("dev:server", ["dev", "focus:dev"]);
grunt.registerTask("deploy", [ grunt.registerTask("deploy", [
// Pre // Pre
"clean", "clean",

View File

@ -15,6 +15,8 @@ $> npm ci
```shell script ```shell script
# Build the application in `dist/` for development # Build the application in `dist/` for development
$> npm run dev $> npm run dev
# Same as above, but automatically rerun it whenever files are changed
$> npm run dev:server
# Build the application in `dist/` for deployment # Build the application in `dist/` for deployment
$> npm run deploy $> npm run deploy
# Remove build files # Remove build files

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{ {
"name": "fwdekker.com", "name": "fwdekker.com",
"version": "0.38.0", "version": "0.38.1",
"description": "The source code of [my personal website](https://fwdekker.com/).", "description": "The source code of [my personal website](https://fwdekker.com/).",
"author": "Felix W. Dekker", "author": "Felix W. Dekker",
"browser": "dist/bundle.js", "browser": "dist/bundle.js",
@ -12,6 +12,7 @@
"scripts": { "scripts": {
"clean": "grunt clean", "clean": "grunt clean",
"dev": "grunt dev", "dev": "grunt dev",
"dev:server": "grunt dev:server",
"deploy": "grunt deploy", "deploy": "grunt deploy",
"test": "mocha -r ts-node/register -r jsdom-global/register src/**/*.spec.ts", "test": "mocha -r ts-node/register -r jsdom-global/register src/**/*.spec.ts",
"coverage": "nyc npm run test" "coverage": "nyc npm run test"
@ -32,6 +33,8 @@
"grunt-cli": "^1.3.2", "grunt-cli": "^1.3.2",
"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-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0", "grunt-text-replace": "^0.4.0",
"grunt-webpack": "^4.0.2", "grunt-webpack": "^4.0.2",
"jsdom": "^16.4.0", "jsdom": "^16.4.0",