josh/Gruntfile.js

77 lines
2.0 KiB
JavaScript
Raw Normal View History

2019-10-31 19:01:41 +01:00
const path = require('path');
2019-10-26 19:29:00 +02:00
module.exports = grunt => {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
2019-10-31 19:01:41 +01:00
default: ["build/"]
2019-10-26 19:29:00 +02:00
},
copy: {
images: {
2019-10-29 18:36:26 +01:00
files: [{expand: true, cwd: "src/main/", src: ["**/*.png", "**/*.ico"], dest: "build/"}]
2019-10-26 19:29:00 +02:00
},
html: {
2019-10-29 18:36:26 +01:00
files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "build/"}]
2019-10-26 19:29:00 +02:00
},
css: {
2019-10-29 18:36:26 +01:00
files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "build/"}]
2019-10-26 19:29:00 +02:00
}
},
2019-10-31 19:01:41 +01:00
webpack: {
options: {
entry: "./src/main/js/main.ts",
module: {
rules: [
{
test: /\.ts$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts"],
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "build/"),
2019-10-26 19:29:00 +02:00
}
2019-10-31 19:01:41 +01:00
},
2019-10-26 19:29:00 +02:00
dev: {
2019-10-31 19:01:41 +01:00
mode: "development",
devtool: "inline-source-map"
2019-10-26 19:29:00 +02:00
},
deploy: {
2019-10-31 19:01:41 +01:00
mode: "production"
2019-10-26 19:29:00 +02:00
}
}
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
2019-10-31 19:01:41 +01:00
grunt.loadNpmTasks("grunt-webpack");
2019-10-26 19:29:00 +02:00
2019-10-31 19:01:41 +01:00
grunt.registerTask("dev", [
2019-10-26 19:29:00 +02:00
// Pre
2019-10-31 19:01:41 +01:00
"clean",
2019-10-26 19:29:00 +02:00
// Copy files
"copy:images",
"copy:html",
"copy:css",
// Compile
2019-10-31 19:01:41 +01:00
"webpack:dev"
2019-10-26 19:29:00 +02:00
]);
grunt.registerTask("deploy", [
// Pre
2019-10-31 19:01:41 +01:00
"clean",
2019-10-26 19:29:00 +02:00
// Copy files
"copy:images",
"copy:html",
"copy:css",
// Compile JS
2019-10-31 19:01:41 +01:00
"webpack:deploy"
2019-10-26 19:29:00 +02:00
]);
2019-10-31 19:01:41 +01:00
grunt.registerTask("default", ["dev"]);
2019-10-26 19:29:00 +02:00
};