autofront 1.5.5 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -12
- package/index.js +10 -3
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -1,26 +1,55 @@
|
|
|
1
1
|
# Autofront
|
|
2
2
|
|
|
3
|
-
Gulp settings for front-end projects.
|
|
3
|
+
[Gulp](https://gulpjs.com) settings for front-end projects.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Requirements
|
|
6
6
|
|
|
7
7
|
It is compatible with version [8.17.0](https://nodejs.org/dist/v8.17.0/) of [Node.js](https://nodejs.org).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Behaviour
|
|
10
|
+
|
|
11
|
+
### Tasks
|
|
12
|
+
|
|
13
|
+
The Gulp ones are the following:
|
|
10
14
|
|
|
11
15
|
- `gulp` or `gulp serve` are for running a test server and develop with live reload.
|
|
12
16
|
- `gulp build` only builds the distributable version.
|
|
13
17
|
- With `gulp serve:dist`, a combination of the above is achieved: Specifically, the server runs this version but without reload.
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
### Support
|
|
20
|
+
|
|
21
|
+
The main supported packages/languages/libraries are:
|
|
22
|
+
|
|
23
|
+
- [Bower](https://bower.io).
|
|
24
|
+
- Preprocessors:
|
|
25
|
+
- HTML: [Pug](https://pugjs.org).
|
|
26
|
+
- CSS:
|
|
27
|
+
- [Less](https://lesscss.org).
|
|
28
|
+
- [Sass](https://sass-lang.com).
|
|
29
|
+
- [AngularJS](https://angularjs.org).
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Gulp file
|
|
34
|
+
|
|
35
|
+
`gulpfile.js` simply would look like:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
require('autofront');
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Optionally, to work with [HTML5 mode](https://docs.angularjs.org/api/ng/provider/$locationProvider#html5Mode), invoke `html5Mode` to prefix path of assets.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
var autofront = require('autofront');
|
|
45
|
+
autofront.html5Mode();
|
|
46
|
+
```
|
|
16
47
|
|
|
17
|
-
|
|
48
|
+
### Folder structure
|
|
18
49
|
|
|
19
50
|
Here is the essential basic organization you must to put in your project:
|
|
20
51
|
|
|
21
52
|
```text
|
|
22
|
-
├─ bower_components/
|
|
23
|
-
├─ nodes_modules/
|
|
24
53
|
├─ src/
|
|
25
54
|
│ ├─ fonts/
|
|
26
55
|
│ ├─ styles/
|
|
@@ -28,16 +57,23 @@ Here is the essential basic organization you must to put in your project:
|
|
|
28
57
|
│ │ ├─ index.less
|
|
29
58
|
│ │ └─ index.scss
|
|
30
59
|
│ └─ index.html
|
|
31
|
-
├─ .gitignore
|
|
32
60
|
├─ bower.json
|
|
33
61
|
├─ gulpfile.js
|
|
34
|
-
├─ package-lock.json
|
|
35
62
|
└─ package.json
|
|
36
63
|
```
|
|
37
64
|
|
|
38
|
-
|
|
65
|
+
In `src`, only `index.html` is required. However, if Sass is used, both files must to exist.
|
|
66
|
+
|
|
67
|
+
### Domains
|
|
68
|
+
|
|
69
|
+
Running Gulp command, an additional parameter can be included (e.g.: `gulp --dev` o `gulp build --pro`) to indicate the domain of connection path. Defaults to local.
|
|
70
|
+
|
|
71
|
+
These domain URLs must to appear listed in `package.json` with the property `domains` (optionally also `domainsAliases`, to assign domain name for each alias).
|
|
72
|
+
|
|
73
|
+
And, to capture the selected URL, put `{{AUTOFRONT_DOMAIN}}` where it would be located in your source code.
|
|
39
74
|
|
|
40
75
|
## Pending
|
|
41
76
|
|
|
42
|
-
- Once the server waits for changes, synchronize also the deletion of files (from `src`).
|
|
43
|
-
-
|
|
77
|
+
- [ ] Once the server waits for changes, synchronize also the deletion of files (from `src`).
|
|
78
|
+
- [ ] Sass errors must not break the Gulp process (like Less).
|
|
79
|
+
- [ ] Bower should be replaced as a dependency manager. It is currently [under maintenance](https://bower.io/blog/2017/how-to-migrate-away-from-bower/) and, therefore, its use is not recommended.
|
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
this.html5Mode = html5Mode;
|
|
2
|
+
|
|
1
3
|
const gulp = require('gulp'),
|
|
2
4
|
args = require('get-gulp-args')(),
|
|
3
5
|
mergeStream = require('merge-stream'),
|
|
@@ -12,9 +14,9 @@ var domain = undefined;
|
|
|
12
14
|
|
|
13
15
|
const allFiles = getFiles(),
|
|
14
16
|
indexHtmlFile = 'index.html',
|
|
15
|
-
stylesFolder = 'styles/',
|
|
16
17
|
cssFilename = 'index',
|
|
17
|
-
cssFullFilename = cssFilename+'.css'
|
|
18
|
+
cssFullFilename = cssFilename+'.css';
|
|
19
|
+
var stylesFolder = 'styles/',
|
|
18
20
|
jsTemplatesFile = 'scripts/templates.js';
|
|
19
21
|
|
|
20
22
|
const paths = {
|
|
@@ -61,7 +63,6 @@ gulp.task('styles', () => {
|
|
|
61
63
|
return gulp.src(paths.src+stylesFolder+cssFilename+'.'+ext).pipe(injStr.prepend((extraCode?extraCode+nl:'')+'// bower:'+ext+nl+'// endbower'+nl)).pipe($.wiredep()).pipe(process()).on('error', notifyError);
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
|
-
|
|
65
66
|
gulp.task('fonts', () => gulp.src(mainBowerFiles()).pipe(filter(['eot','otf','svg','ttf','woff','woff2'], true)).pipe(gulp.dest(paths.tmp+'fonts/')));
|
|
66
67
|
gulp.task('others', () => {
|
|
67
68
|
const pugFilter = filter('pug');
|
|
@@ -119,6 +120,12 @@ gulp.task('serve:dist', ['build'], () => browserSyncInit(paths.dist));
|
|
|
119
120
|
|
|
120
121
|
gulp.task('default', ['serve']);
|
|
121
122
|
|
|
123
|
+
function html5Mode() {
|
|
124
|
+
const pathPrefix = '/';
|
|
125
|
+
stylesFolder = pathPrefix + stylesFolder;
|
|
126
|
+
jsTemplatesFile = pathPrefix + jsTemplatesFile;
|
|
127
|
+
}
|
|
128
|
+
|
|
122
129
|
function getFiles(ext) {
|
|
123
130
|
ext = ext || '*';
|
|
124
131
|
const isArray = typeof ext != 'string';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autofront",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Gulp settings for front-end projects.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
"url": "git+https://github.com/mvicens/autofront.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
|
-
"gulp"
|
|
14
|
+
"gulp",
|
|
15
|
+
"bower",
|
|
16
|
+
"pug",
|
|
17
|
+
"less",
|
|
18
|
+
"sass",
|
|
19
|
+
"angularjs"
|
|
15
20
|
],
|
|
16
21
|
"author": "Miquel Alejandro Vicens Dalmau",
|
|
17
22
|
"license": "ISC",
|