|
| 1 | +const MODE_DEVELOPMENT = 'dev'; |
| 2 | +const eleventyNavigationPlugin = require('@11ty/eleventy-navigation'); |
| 3 | +const htmlmin = require('html-minifier'); |
| 4 | + |
| 5 | +const now = new Date(); |
| 6 | +const {MODE: mode} = process.env; |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +module.exports = function (config) { |
| 13 | + config.addPassthroughCopy({'_src/assets/_domain/cname.txt': '/CNAME'}); |
| 14 | + config.addPassthroughCopy({'_src/assets/_domain/humans.txt': '/humans.txt'}); |
| 15 | + config.addPassthroughCopy({'_src/assets/_icon/favicon.ico': '/favicon.ico'}); |
| 16 | + config.addPassthroughCopy('_src/**/img/*.*'); |
| 17 | + config.addPassthroughCopy('_src/assets/fonts'); |
| 18 | + config.addPassthroughCopy('_src/assets/css/*.css'); |
| 19 | + config.addPassthroughCopy('_src/assets/images'); |
| 20 | + config.addPassthroughCopy('_src/assets/js/**/*.js'); |
| 21 | + if (mode !== 'pro') { |
| 22 | + config.addPassthroughCopy('_src/assets/css/*.map'); |
| 23 | + config.addPassthroughCopy('_src/assets/js/**/*.map'); |
| 24 | + } |
| 25 | + |
| 26 | + config.addPlugin(eleventyNavigationPlugin); |
| 27 | + |
| 28 | + |
| 29 | + config.addTransform('htmlmin', function (content, outputPath) { |
| 30 | + if (mode === 'pro' && outputPath && outputPath.endsWith('.html')) { |
| 31 | + const minified = htmlmin.minify(content, { |
| 32 | + useShortDoctype: true, |
| 33 | + removeComments: true, |
| 34 | + collapseWhitespace: true, |
| 35 | + preserveLineBreaks: false |
| 36 | + }); |
| 37 | + |
| 38 | + return minified; |
| 39 | + } |
| 40 | + |
| 41 | + return content; |
| 42 | + }); |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + return { |
| 53 | + dir: { |
| 54 | + input: '_src', |
| 55 | + output: 'dist', |
| 56 | + includes: '_templates', |
| 57 | + data: '_data', |
| 58 | + }, |
| 59 | + templateFormats: ['njk', 'md'], |
| 60 | + htmltemplateEngine: 'njk', |
| 61 | + markdownTemplateEngine: 'njk', |
| 62 | + } |
| 63 | +} |
0 commit comments