Commit d0aeaeb2 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

First version.

parents
/node_modules/
/dist/*
const { readdirSync } = require("fs");
module.exports = grunt => {
const host = "127.0.0.1";
const liveReloadPort = 8899;
const revealJsSources = ["js/**/*.js", "css/**/*.css", "lib/**", "plugin/**"];
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
"http-server": {
dev: {
host,
root: "dist",
runInBackground: true,
openBrowser: true
}
},
watcher: {
configFiles: {
files: ["Gruntfile.js"]
},
presentations: {
files: "src/**/*.md",
tasks: [],
options: {
debounceDelay: 1000,
event: ["add", "change"],
spawn: false,
livereload: liveReloadPort
}
},
revealjs: {
files: revealJsSources,
task: ["build:revealjs"],
options: {
cwd: "node_modules/reveal.js/."
}
}
},
exec: {
build: {
cmd: (pres, env) =>
[
"pandoc",
"--from=markdown+smart",
`../src/${pres}.md`,
"--to=revealjs",
`--output=./${pres}${env !== "prod" ? "-" + env : ""}.html`,
"--standalone",
"--toc",
"--slide-level=2",
"--variable=theme:irstea",
"--variable=history:true",
env === "dev" &&
`--variable=header-includes='<script src="//${host}:${liveReloadPort}/livereload.js"></script>'`
]
.filter(v => !!v)
.join(" "),
cwd: "dist",
stdout: true,
stderr: true
}
},
copy: {
revealjs: {
expand: true,
cwd: "node_modules/reveal.js/.",
src: revealJsSources,
dest: "dist/reveal.js/"
}
},
clean: ["dist/**"]
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-http-server");
grunt.loadNpmTasks("grunt-watcher");
grunt.registerTask("default", ["build"]);
grunt.registerTask("serve", ["http-server", "build:dev", "watcher"]);
grunt.registerTask("build:revealjs", ["copy:revealjs"]);
grunt.registerTask("build", env =>
grunt.task.run(["build:revealjs", `build:pres:${env || "prod"}`])
);
const enqueueBuilds = (paths, env) =>
grunt.task.run(
paths
.filter(name => name.endsWith(".md"))
.map(
name =>
`exec:build:${name.substr(0, name.length - 3)}:${env || "prod"}`
)
);
grunt.registerTask("build:pres", env =>
enqueueBuilds(readdirSync("src/"), env)
);
grunt.event.removeAllListeners("chokidar");
grunt.event.on("chokidar", function(_, filepath, target) {
if (target === "presentations") {
enqueueBuilds([filepath.substr(4)], "dev");
}
});
};
This diff is collapsed.
This diff is collapsed.
dist/reveal.js
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment