-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.js
145 lines (131 loc) · 4.18 KB
/
builder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var nunjucks = require('nunjucks')
var fs = require('fs');
var env = new nunjucks.Environment(new nunjucks.FileSystemLoader('../coraline-docs/website'));
/**
* CORALINE FRAMEWORK BINARY
*/
var frameworkBinary = '../coralinecss';
if (!fs.existsSync(frameworkBinary)){
fs.mkdirSync(frameworkBinary);
}
var frameworkSources = frameworkBinary+'/coraline-v0.6.2';
if (!fs.existsSync(frameworkSources)){
fs.mkdirSync(frameworkSources);
}
fs.copyFileSync('README.md', frameworkBinary+'/README.md');
fs.copyFileSync('LICENSE', frameworkBinary+'/LICENSE');
fs.copyFileSync('base.scss', frameworkBinary+'/base.scss');
fs.copyFileSync('base.css', frameworkBinary+'/base.css');
/**
* coralinecss.com DOCUMENTATION
*/
var docsPath = '../coraline-docs';
if (!fs.existsSync(docsPath)){
fs.mkdirSync(docsPath);
}
var docsSourcesPath = docsPath+'/coraline-v0.6.2';
if (!fs.existsSync(docsSourcesPath)){
fs.mkdirSync(docsSourcesPath);
}
var index = env.render('index.njk.html')
fs.writeFileSync(docsPath+'/index.html', index);
const documentation = [
{
canonical: '/getting-started.html',
njk: 'getting-started.njk.html',
current: 'getting-started'
},
/**
* COMPONENTS
*/
{
/**
* Alternative CSS only framework
*/
title: 'Card • Flexible component for displaying content',
canonical: '/card.html',
njk: 'components/card.njk.html',
description: 'Card: A flexible UI component for displaying visual and text content',
current: 'card'
},
{
title: 'Comment • A flexible social interface component',
canonical: '/comment.html',
njk: 'components/comment.njk.html',
description: 'Comment: A flexible social interface component for displaying visual and text content',
current: 'comment'
},
{
title: 'Navbar • A CSS only and fully responsive navbar',
canonical: '/navbar.html',
njk: 'components/navbar.njk.html',
description: 'Navbar: A CSS only, fully responsive and easy to implement navbar menu',
current: 'navbar'
},
/**
* GRID SYSTEM
*/
{
title: 'Grid system • Simple and easy to learn grid system',
canonical: '/grid-system.html',
njk: 'grid-system.njk.html',
description: 'Grid system: A simple and easy to learn grid system, that is adaptable to all screens',
current: 'grid-system'
},
/**
* ELEMENTS
*/
{ title: 'Button • A customizable element through CSS classes',
canonical: '/button.html',
njk: 'elements/button.njk.html',
description: 'Button: A useful element with multiple ways to customize through CSS classes',
current: 'button'
},
{ title: 'Tags • Small, nice element that is also customizable',
canonical: '/tags.html',
njk: 'elements/tags.njk.html',
description: 'Tags: A small, nice element with multiple ways to customize through CSS classes',
current: 'tags'
},
{ title: 'Circular img • Element for showing circular images',
canonical: '/circular-img.html',
njk: 'elements/circular-img.njk.html',
description: 'Circular img: Circular img element that is also customizable through CSS classes',
current: 'circular-img'
},
];
for (let index = 0; index < documentation.length; index++) {
let element = documentation[index];
var rendered = env.render(element.njk, element)
fs.writeFileSync(docsPath+element.canonical, rendered);
}
/**
* NODE SASS
*/
var sass = require('node-sass');
var scss_content = fs.readFileSync('base.scss').toString()
var sassResult = sass.renderSync({
data: scss_content
});
/**
* BASE CSS CODE
*/
var baseCss = sassResult.css;
fs.writeFileSync('base.css', baseCss);
// CSS minifier
var csso = require('csso');
/**
* AUTOPREFIXER
*/
const autoprefixer = require('autoprefixer')
const postcss = require('postcss')
postcss([ autoprefixer ]).process(baseCss,{from: undefined}).then(result => {
result.warnings().forEach(warn => {
console.warn(warn.toString())
})
var minifiedCss = csso.minify(result.css).css;
fs.writeFileSync('coraline-v0.6.2/coraline.min.css', minifiedCss);
fs.writeFileSync(docsSourcesPath+'/coraline.min.css', minifiedCss);
fs.writeFileSync(frameworkSources+'/coraline.min.css', minifiedCss);
console.log('Coraline is ready!')
})