Skip to content

Commit

Permalink
feat: add a project template + add package descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
trustedtomato committed Oct 31, 2021
1 parent c28660e commit c3263ec
Show file tree
Hide file tree
Showing 14 changed files with 5,112 additions and 21 deletions.
11 changes: 0 additions & 11 deletions examples/blog/public/favicon.svg

This file was deleted.

26 changes: 26 additions & 0 deletions packages/create-decharge/templates/hello-world/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
env: {
es2021: true,
node: true
},
extends: [
'preact',
'standard'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 12,
sourceType: 'module'
},
plugins: [
'@typescript-eslint'
],
rules: {
'no-useless-constructor': 1,
'react/no-danger': 0,
'react/display-name': [0]
}
}
4 changes: 4 additions & 0 deletions packages/create-decharge/templates/hello-world/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
node_modules/
public/generated/
.decharge/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
snippetOptions: {
rule: {
match: /<\/title>/i,
fn: (snippet, match) => match + snippet
}
}
}
70 changes: 70 additions & 0 deletions packages/create-decharge/templates/hello-world/minify-dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { minify } from 'html-minifier-terser'
import CleanCss from 'clean-css'
import readdirp from 'readdirp'
import fs from 'fs/promises'
import { minify as minifyJs } from 'uglify-js'

for await (const { fullPath } of readdirp('dist', { fileFilter: '*.html' })) {
fs.writeFile(
fullPath,
minify(
await fs.readFile(fullPath, 'utf-8'), {
caseSensitive: false,
collapseBooleanAttributes: true,
collapseInlineTagWhitespace: false,
collapseWhitespace: true,
conservativeCollapse: false,
continueOnParseError: true,
decodeEntities: true,
html5: true,
includeAutoGeneratedTags: false,
keepClosingSlash: false,
maxLineLength: 0,
minifyCSS: true,
minifyJS: true,
preserveLineBreaks: false,
preventAttributesEscaping: false,
processConditionalComments: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeEmptyElements: false,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
removeTagWhitespace: true,
sortAttributes: true,
sortClassName: true,
trimCustomFragments: true,
useShortDoctype: true
}
)
)
}

const cssCleaner = new CleanCss()

for await (const { fullPath } of readdirp('dist', { fileFilter: '*.css' })) {
fs.writeFile(
fullPath,
cssCleaner.minify(
await fs.readFile(fullPath, 'utf-8')
).styles
)
}

for await (const { fullPath } of readdirp('dist', { fileFilter: '*.js' })) {
fs.writeFile(
fullPath,
minifyJs(
await fs.readFile(fullPath, 'utf-8'), {
compress: {
drop_console: true,
unsafe_math: true,
unsafe_undefined: true
}
}
).code
)
}
43 changes: 43 additions & 0 deletions packages/create-decharge/templates/hello-world/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "decharge-blog",
"private": true,
"version": "0.0.1",
"description": "",
"type": "module",
"author": "Tamás Halasi",
"scripts": {
"build": "decharge build && node minify-dist.js",
"watch": "decharge watch",
"dev-serve": "browser-sync dist/ --config browser-sync.config.cjs --watch"
},
"license": "ISC",
"dependencies": {
"@types/gm": "^1.18.9",
"@types/node-fetch": "^2.5.10",
"browser-sync": "^2.27.7",
"clean-css": "^5.1.3",
"decharge": "workspace:*",
"gm": "^1.23.1",
"gray-matter": "^4.0.3",
"html-minifier-terser": "^5.1.1",
"mkdirp": "^1.0.4",
"node-fetch": "^2.6.1",
"p-event": "^4.2.0",
"preact": "^10.5.13",
"precinct": "^8.1.0",
"readdirp": "^3.6.0",
"striptags": "^3.2.0",
"typescript": "^4.3.4",
"uglify-js": "^3.13.10"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"eslint": "^7.12.1",
"eslint-config-preact": "^1.1.4",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1"
}
}
Loading

0 comments on commit c3263ec

Please sign in to comment.