forked from tools/josh
1
0
Fork 0
josh/Gruntfile.js

94 lines
2.4 KiB
JavaScript

const path = require('path');
module.exports = grunt => {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
default: ["build/"]
},
copy: {
images: {
files: [{expand: true, cwd: "src/main/", src: ["**/*.png", "**/*.ico"], dest: "build/"}]
},
html: {
files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "build/"}]
},
css: {
files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "build/"}]
}
},
replace: {
default: {
src: "./build/bundle.js",
replacements: [
{
from: "%%VERSION_NUMBER%%",
to: "<%= pkg.version %>"
}
],
overwrite: true
}
},
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/"),
}
},
dev: {
mode: "development",
devtool: "inline-source-map"
},
deploy: {
mode: "production"
}
}
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-text-replace");
grunt.loadNpmTasks("grunt-webpack");
grunt.registerTask("dev", [
// Pre
"clean",
// Copy files
"copy:images",
"copy:html",
"copy:css",
// Compile
"webpack:dev",
// Post
"replace"
]);
grunt.registerTask("deploy", [
// Pre
"clean",
// Copy files
"copy:images",
"copy:html",
"copy:css",
// Compile JS
"webpack:deploy",
// Post
"replace"
]);
grunt.registerTask("default", ["dev"]);
};