template/Gruntfile.js

91 lines
2.6 KiB
JavaScript

const path = require("path");
module.exports = grunt => {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
default: ["dist/"],
},
cssmin: {
target: {
files: {
"dist/template.css": "src/main/css/main.css",
},
},
},
focus: {
deploy: {
include: ["css", "storage", "template"],
},
},
webpack: {
storage: {
entry: "./src/main/js/Storage.ts",
module: {
rules: [
{
test: /\.ts$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts"],
},
output: {
filename: "storage.js",
path: path.resolve(__dirname, "dist/"),
},
mode: "production",
},
template: {
entry: "./src/main/js/template.js",
module: {
rules: [
{
test: /\.js$/i,
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts"],
},
output: {
library: "fwdekker-template",
libraryTarget: "umd",
filename: "template.js",
path: path.resolve(__dirname, "dist"),
},
mode: "production",
},
},
watch: {
css: {
files: ["src/main/**/*.css"],
tasks: ["cssmin"],
},
storage: {
files: ["src/main/**/*.ts"],
tasks: ["webpack:storage"],
},
template: {
files: ["src/main/**/*.js"],
tasks: ["webpack:template"],
},
},
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-focus");
grunt.loadNpmTasks("grunt-webpack");
grunt.registerTask("deploy", ["webpack:storage", "webpack:template", "cssmin"]);
grunt.registerTask("deploy:server", ["deploy", "focus:deploy"]);
grunt.registerTask("default", ["deploy"]);
};