Skip to content

Commit

Permalink
chore(JS): use npm script for docs' JS and handle watching them
Browse files Browse the repository at this point in the history
  • Loading branch information
ffoodd committed Mar 3, 2022
1 parent 7d1d3e8 commit 09fc9a4
Show file tree
Hide file tree
Showing 6 changed files with 1,452 additions and 68 deletions.
1 change: 1 addition & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`)

eleventyConfig.addWatchTarget('site/static/docs.css')
eleventyConfig.addWatchTarget('site/static/docs.js')

eleventyConfig.setBrowserSyncConfig({
ui: false,
Expand Down
12 changes: 0 additions & 12 deletions a11y.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const fm = require('front-matter')
const prism = require('prismjs')
const loadLanguages = require('prismjs/components/');
loadLanguages(['scss', 'css-extras']);
const uglify = require('uglify-es')

const DIRECTORIES = {
css: {
Expand All @@ -30,16 +29,6 @@ const DIRECTORIES = {
DIRECTORIES.assets.js.output = DIRECTORIES.static
DIRECTORIES.css.output = DIRECTORIES.static + 'css/'

const parseAssets = () => {
/**
* Process docs styles and scripts
*/
const JS = fs.readFileSync(DIRECTORIES.assets.js.input + 'docs.js', 'utf8')

// Uglify and write JS output file
fs.writeFileSync(DIRECTORIES.assets.js.output + 'docs.js', uglify.minify(JS).code)
}

const processSassDocumentation = file => {
const inputFileExtension = path.extname(file)
const inputFilename = path.basename(file, inputFileExtension)
Expand Down Expand Up @@ -166,6 +155,5 @@ const generateJsonDocumentation = () => {
}

module.exports = function () {
parseAssets()
generateJsonDocumentation()
}
2 changes: 1 addition & 1 deletion docs/static/docs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 09fc9a4

Please sign in to comment.