114 lines
3.4 KiB
JavaScript
114 lines
3.4 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", "validation"],
|
|
},
|
|
},
|
|
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.ts",
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
use: "ts-loader",
|
|
exclude: /node_modules/,
|
|
},
|
|
],
|
|
},
|
|
resolve: {
|
|
extensions: [".ts"],
|
|
},
|
|
output: {
|
|
filename: "template.js",
|
|
path: path.resolve(__dirname, "dist"),
|
|
},
|
|
mode: "production",
|
|
},
|
|
validation: {
|
|
entry: "./src/main/js/Validation.ts",
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
use: "ts-loader",
|
|
exclude: /node_modules/,
|
|
},
|
|
],
|
|
},
|
|
resolve: {
|
|
extensions: [".ts"],
|
|
},
|
|
output: {
|
|
filename: "validation.js",
|
|
path: path.resolve(__dirname, "dist/"),
|
|
},
|
|
mode: "production",
|
|
},
|
|
},
|
|
watch: {
|
|
css: {
|
|
files: ["src/main/**/*.css"],
|
|
tasks: ["cssmin"],
|
|
},
|
|
storage: {
|
|
files: ["src/main/js/Storage.ts"],
|
|
tasks: ["webpack:storage"],
|
|
},
|
|
template: {
|
|
files: ["src/main/js/Template.ts"],
|
|
tasks: ["webpack:template"],
|
|
},
|
|
validation: {
|
|
files: ["src/main/js/Validation.ts"],
|
|
tasks: ["webpack:validation"],
|
|
},
|
|
},
|
|
});
|
|
|
|
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", "webpack:validation", "cssmin"]);
|
|
grunt.registerTask("deploy:server", ["deploy", "focus:deploy"]);
|
|
|
|
grunt.registerTask("default", ["deploy"]);
|
|
};
|