Skip to content

Commit 63d86ed

Browse files
Adiciona estrutura que facilita instalação e compilação de less para css.
1 parent 1a12906 commit 63d86ed

3 files changed

Lines changed: 79 additions & 5 deletions

File tree

Gruntfile.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
// load all grunt tasks
5+
grunt.loadNpmTasks('grunt-contrib-less');
6+
grunt.loadNpmTasks('grunt-contrib-watch');
7+
grunt.loadNpmTasks('grunt-contrib-cssmin');
8+
9+
grunt.initConfig({
10+
watch: {
11+
// if any .less file changes in directory "public/css/" run the "less"-task.
12+
files: ["assets/static/less/**/*.less"],
13+
tasks: ["less", "cssmin"]
14+
},
15+
// "less"-task configuration
16+
less: {
17+
// production config is also available
18+
development: {
19+
options: {
20+
// Specifies directories to scan for @import directives when parsing.
21+
// Default value is the directory of the source, which is probably what you want.
22+
paths: ["assets/static/less/"],
23+
},
24+
files: {
25+
// compilation.css : source.less
26+
"assets/static/css/main.unminified.css": "assets/static/less/main.css.less"
27+
}
28+
},
29+
},
30+
cssmin: {
31+
target: {
32+
files: {
33+
'assets/static/css/main.css': ['assets/static/css/main.unminified.css']
34+
}
35+
}
36+
},
37+
});
38+
// the default task (running "grunt" in console) is "watch"
39+
grunt.registerTask('default', ['watch']);
40+
};

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@ lektor build -O /path/to/build/
2020
Sendo que o diretório informado depois do parâmetro -O irão conter os novos estáticos gerados pelo Lektor.
2121

2222
## Estilização (CSS)
23-
Utilizamos o LESS e um plugin para minificação:
23+
Utilizamos o LESS e um plugin para minificação. Para poder usar, temos que instalar as dependências do npm:
2424

2525
```
26-
npm install -g less
27-
npm install -g less-plugin-clean-css
26+
npm install
2827
```
2928

30-
Enquanto não automatizamos esse processo, para gerar o CSS é preciso executar o seguinte comando dentro da pasta `static`:
29+
Para rodar a compilação manualmente, é só usar o seguinte comando:
3130

3231
```
33-
lessc --clean-css="-b --compatibility=ie8 --advanced" less/main.css.less css/main.css
32+
npm run build:css
33+
```
34+
35+
Caso você queira rodar um watcher, que vai observar todos os arquivos less e compilá-los quando notar que você salvou algum deles, usa esse comando aqui, ó:
36+
37+
```
38+
npm run watch:css
3439
```

package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "pythonrio.github.io",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "",
6+
"dependencies": {},
7+
"devDependencies": {
8+
"grunt": "^0.4.5",
9+
"grunt-cli": "^0.1.13",
10+
"grunt-contrib-cssmin": "^0.14.0",
11+
"grunt-contrib-less": "^1.2.0",
12+
"grunt-contrib-watch": "^0.6.1",
13+
"less": "^2.6.0",
14+
"less-plugin-clean-css": "^1.5.1"
15+
},
16+
"scripts": {
17+
"lessc": "./node_modules/.bin/lessc",
18+
"grunt": "./node_modules/.bin/grunt",
19+
"build:css": "npm run lessc --clean-css='-b --compatibility=ie8 --advanced' assets/static/less/main.css.less assets/static/css/main.css",
20+
"watch:css": "npm run grunt"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/pythonrio/pythonrio.github.io.git"
25+
},
26+
"author": "",
27+
"license": "ISC",
28+
"homepage": "https://pythonrio.github.io/"
29+
}

0 commit comments

Comments
 (0)