autofront 1.5.7 → 2.0.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.
Files changed (3) hide show
  1. package/README.md +10 -7
  2. package/index.js +27 -30
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  [Gulp](https://gulpjs.com) settings for front-end projects.
4
4
 
5
- ## Requirements
6
-
7
- It is compatible with version [8.17.0](https://nodejs.org/dist/v8.17.0/) of [Node.js](https://nodejs.org).
8
-
9
5
  ## Behaviour
10
6
 
11
7
  ### Tasks
@@ -38,6 +34,13 @@ The main supported packages/languages/libraries are:
38
34
  require('autofront');
39
35
  ```
40
36
 
37
+ Optionally, to work with [HTML5 mode](https://docs.angularjs.org/api/ng/provider/$locationProvider#html5Mode), invoke `html5Mode` to prefix path of assets.
38
+
39
+ ```js
40
+ var autofront = require('autofront');
41
+ autofront.html5Mode();
42
+ ```
43
+
41
44
  ### Folder structure
42
45
 
43
46
  Here is the essential basic organization you must to put in your project:
@@ -67,6 +70,6 @@ And, to capture the selected URL, put `{{AUTOFRONT_DOMAIN}}` where it would be l
67
70
 
68
71
  ## Pending
69
72
 
70
- - [ ] Once the server waits for changes, synchronize also the deletion of files (from `src`).
71
- - [ ] Sass errors must not break the Gulp process (like Less).
72
- - [ ] 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.
73
+ - Once the server waits for changes, synchronize also the deletion of files (from `src`).
74
+ - Sass errors must not break the Gulp process (like Less).
75
+ - 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,10 +1,12 @@
1
+ this.html5Mode = html5Mode;
2
+
1
3
  const gulp = require('gulp'),
2
4
  args = require('get-gulp-args')(),
3
5
  mergeStream = require('merge-stream'),
4
6
  mainBowerFiles = require('main-bower-files'),
5
7
  $ = require('gulp-load-plugins')(),
6
8
  injStr = $.injectString,
7
- gulpSync = $.sync(gulp),
9
+ gulpSass = $.sass(require('sass')),
8
10
  notifyError = $.notify.onError(error => error.message),
9
11
  browserSync = require('browser-sync').create();
10
12
 
@@ -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 = {
@@ -48,12 +50,9 @@ gulp.task('check', () => {
48
50
  gulp.task('del', () => delFolder(paths.tmp));
49
51
  gulp.task('index-build', () => gulp.src(paths.srcIndexHtml).pipe(injStr.after('<!-- endbuild -->', nl+tab+'<link rel="stylesheet" href="'+stylesFolder+cssFullFilename+'">')).pipe($.inject(gulp.src(paths.srcJs).pipe($.angularFilesort()), {relative: true})).on('error', notifyError).pipe($.wiredep()).pipe($.useref()).pipe(gulp.dest(paths.tmp)));
50
52
  gulp.task('index-domain', () => gulp.src(paths.tmp+getFiles('js')).pipe(injStr.replace('{{AUTOFRONT_DOMAIN}}', domain)).pipe(gulp.dest(paths.tmp)));
51
- gulp.task('index', gulpSync.sync([
52
- 'index-build',
53
- 'index-domain'
54
- ]));
53
+ gulp.task('index', gulp.series('index-build', 'index-domain'));
55
54
  gulp.task('styles', () => {
56
- return mergeStream(getCssStream('scss', $.sass, '@import "variables";'), getCssStream('less', $.less))
55
+ return mergeStream(getCssStream('scss', gulpSass, '@import "variables";'), getCssStream('less', $.less))
57
56
  .pipe($.concat(cssFullFilename))
58
57
  .pipe(gulp.dest(paths.tmp+stylesFolder));
59
58
 
@@ -69,34 +68,26 @@ gulp.task('others', () => {
69
68
  .pipe(gulp.dest(paths.tmp));
70
69
  });
71
70
  gulp.task('about', () => gulp.src('package.json').pipe($.about()).pipe(gulp.dest(paths.tmp)));
72
- gulp.task('build:tmp', gulpSync.sync([
73
- 'del',
74
- 'check',
75
- ['index', 'styles', 'fonts', 'others', 'about']
76
- ]));
77
- gulp.task('browser', ['build:tmp'], () => browserSyncInit(paths.tmp));
78
- gulp.task('serve', ['browser'], () => {
79
- gulp.watch([paths.srcIndexHtml, paths.srcJs], ['index']);
80
- gulp.watch([paths.srcSass, paths.srcLess], ['styles']);
81
- gulp.watch(paths.srcOthers, ['others']);
71
+ gulp.task('build:tmp', gulp.series('del', 'check', gulp.parallel('index', 'styles', 'fonts', 'others', 'about')));
72
+ gulp.task('browser', gulp.series('build:tmp', (cb) => {
73
+ browserSyncInit(paths.tmp);
74
+ cb();
75
+ }));
76
+ exports.serve = gulp.series('browser', () => {
77
+ gulp.watch([paths.srcIndexHtml, paths.srcJs], gulp.task('index'));
78
+ gulp.watch([paths.srcSass, paths.srcLess], gulp.task('styles'));
79
+ gulp.watch(paths.srcOthers, gulp.task('others'));
82
80
  gulp.watch(paths.tmp+allFiles, function(event) {
83
81
  browserSync.reload(event.path);
84
82
  });
85
83
  });
86
84
 
87
85
  gulp.task('del:dist', () => delFolder(paths.dist));
88
- gulp.task('copy', ['del:dist'], () => gulp.src(paths.tmp+allFiles).pipe(gulp.dest(paths.dist)));
86
+ gulp.task('copy', gulp.series('del:dist', () => gulp.src(paths.tmp+allFiles).pipe(gulp.dest(paths.dist))));
89
87
  gulp.task('templates-build', () => gulp.src([paths.dist+getFiles('html'), '!'+paths.dist+indexHtmlFile]).pipe($.cleanDest(paths.dist)).pipe(minifyHtml()).pipe($.angularTemplatecache(jsTemplatesFile, {module: 'app'})).pipe(gulp.dest(paths.dist)));
90
88
  gulp.task('templates-clean', () => require('delete-empty')(paths.dist));
91
- gulp.task('templates', gulpSync.sync([
92
- 'templates-build',
93
- 'templates-clean'
94
- ]));
95
- gulp.task('build', gulpSync.sync([
96
- 'build:tmp',
97
- 'copy',
98
- 'templates'
99
- ]), () => {
89
+ gulp.task('templates', gulp.series('templates-build', 'templates-clean'));
90
+ exports.build = gulp.series('build:tmp', 'copy', 'templates', () => {
100
91
  const indexHtmlFilter = filter('html'),
101
92
  cssFilter = filter('css'),
102
93
  jsFilter = filter('js'),
@@ -114,9 +105,15 @@ gulp.task('build', gulpSync.sync([
114
105
  .pipe($.size({showFiles: true}))
115
106
  .pipe(gulp.dest(paths.dist));
116
107
  });
117
- gulp.task('serve:dist', ['build'], () => browserSyncInit(paths.dist));
108
+ exports['serve:dist'] = gulp.series(exports.build, () => browserSyncInit(paths.dist));
109
+
110
+ exports.default = exports.serve;
118
111
 
119
- gulp.task('default', ['serve']);
112
+ function html5Mode() {
113
+ const pathPrefix = '/';
114
+ stylesFolder = pathPrefix + stylesFolder;
115
+ jsTemplatesFile = pathPrefix + jsTemplatesFile;
116
+ }
120
117
 
121
118
  function getFiles(ext) {
122
119
  ext = ext || '*';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autofront",
3
- "version": "1.5.7",
3
+ "version": "2.0.0",
4
4
  "description": "Gulp settings for front-end projects.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,7 +28,7 @@
28
28
  "browser-sync": "^2.26.3",
29
29
  "delete-empty": "^2.0.0",
30
30
  "get-gulp-args": "0.0.1",
31
- "gulp": "^3.9.1",
31
+ "gulp": "^4.0.2",
32
32
  "gulp-about": "^1.1.0",
33
33
  "gulp-angular-filesort": "^1.2.1",
34
34
  "gulp-angular-templatecache": "^2.2.3",
@@ -50,13 +50,13 @@
50
50
  "gulp-rev": "^8.1.1",
51
51
  "gulp-rev-delete-original": "^0.2.3",
52
52
  "gulp-rev-replace": "^0.4.4",
53
- "gulp-sass": "^4.0.2",
53
+ "gulp-sass": "^5.0.0",
54
54
  "gulp-size": "^3.0.0",
55
- "gulp-sync": "^0.1.4",
56
55
  "gulp-terser": "^1.1.7",
57
56
  "gulp-useref": "^3.1.6",
58
57
  "gulp-wiredep": "^1.2.0",
59
58
  "main-bower-files": "^2.13.1",
60
- "merge-stream": "^1.0.1"
59
+ "merge-stream": "^1.0.1",
60
+ "sass": "^1.38.2"
61
61
  }
62
62
  }