Gulp Build does not copy files in server views folders to dist
- [x] I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests.
| Item | Version |
|---|---|
| generator-angular-fullstack | v4.2.0 / v4.2.2 |
| Node | v8.1.2 |
| npm | 5.4.0 |
| Operating System | Ubuntu 17.04 |
| browser | chrome / firefox |
| Item | Answer |
|---|---|
| Transpiler | Babel |
| Markup | HTML |
| CSS | SCSS |
| Router | ui-router |
| Client Tests | Mocha |
| DB | MongoDB |
| Auth | Y |
When i run gulp build the views folder is not copied to dist/server. My production server is complaining :)
Could you share more information, please? How is your build task? How much did you change it from the original version?
THIS WORKS, plz reference your gulpfile.js:
/**
* Created by JHOELLER on 8/17/2017.
*/
var gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
cache = require('gulp-cache'),
sass = require('gulp-sass'),
browserSync = require('browser-sync').create(),
jshint = require('gulp-jshint'),
ngAnnotate = require('gulp-ng-annotate'),
useref = require('gulp-useref'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
gulpIf = require('gulp-if'),
del = require('del'),
runSequence = require('run-sequence'),
cssnano = require('gulp-cssnano'),
mocha = require('gulp-mocha'),
util = require('gulp-util'),
istanbul = require('gulp-istanbul'),
stripDebug = require('gulp-strip-debug');
//removes debugger, console.log, alert statements from JS
gulp.task('debug', function () {
return gulp.src('production/js/*.js')
.pipe(stripDebug())
.pipe(gulp.dest('production'));
});
//Concats and minifies JS
gulp.task('scripts', function() {
return gulp.src('development/js/**/*.js')
.pipe(stripDebug())
.pipe(ngAnnotate())
.pipe(concat('app.min.js'))
.pipe(gulp.dest('production/js'))
});
//Builds SASS into CSS
gulp.task('sass',function(){
gulp.src('development/scss/*.scss')
.pipe(sass())
.pipe(concat('vmar-v2.2.1.styles.css'))
.pipe(gulp.dest('development/css'))
.pipe(browserSync.reload({
stream: true
}));
});
//Minifies all CSS for production
gulp.task('css', function(){
return gulp.src('development/*.html ')
.pipe(useref())
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('production'))
});
//Build virtual server and compile SASS
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: 'development'
},
})
});
gulp.task('serve-dev',['browserSync', 'sass'],function(){
gulp.watch('development/scss/*.scss', ['sass']);
// Reloads the browser whenever HTML or JS files change
gulp.watch('development/*.html', browserSync.reload);
gulp.watch('development/js/**/*.js', browserSync.reload);
});
gulp.task('move-fonts', function() {
return gulp.src('development/fonts/**/*')
.pipe(gulp.dest('production/fonts'))
});
gulp.task('move-images', function() {
return gulp.src('development/images/**/*')
.pipe(gulp.dest('production/images'))
});
gulp.task('move-partials', function(){
return gulp.src('development/partials/**/*')
.pipe(gulp.dest('production/partials'))
});
//Cleaning up generated files automatically
gulp.task('clean:production', function() {
return del.sync('production');
});
//serve-prod but in sequence
gulp.task('buildprod', function (callback) {
runSequence('clean:production',
['sass', 'css', 'scripts', 'move-images', 'move-fonts', 'move-partials'],
callback
);
});
//serve-dev in sequence
gulp.task('servedev', function (callback) {
runSequence(['browserSync'],
callback
);
});
//lint code
gulp.task('lint', function() {
return gulp.src('app/js/**/*.js')
.pipe(jshint('app/.jshintrc'))
.pipe(jshint.reporter());
});
//run unit tests
// gulp test
gulp.task('test', function () {
return gulp.src(['test/*.js'], { read: false })
.pipe(mocha({ reporter: 'spec' }))
.on('error', util.log);
});
gulp.task('watch-test', function () {
gulp.watch(['views/**', 'public/**', 'app.js', 'framework/**', 'test/**'], ['test']);
});`
@rombernardino I have not modified my gulpfile.babel.js . I'm using gulp build
The current gulpfile.babel.js given by the v4.2.2 yo generator does not copy the server/views to dist/server/views.
I added this to the server:copy and it works
gulp.task('copy:server', () => {
return gulp.src([
'package.json', `${serverPath}/views/**/*.html`
], {cwdbase: true})
.pipe(gulp.dest(paths.dist));
});
Now i have the views folder under dist/sever
There is probably a prettier way to do it. I guess it would probably save someone else some confusion if this were included by default.
@rollermy, by default, the only HTML file that's in the server/views is the one for 404 errors. I think that task you created is pretty good for it and maybe they could add it to the main code.