Comments (10)
Faced the same problem. Maybe there is some other options which must be enabled?
from gulp-webserver.
Same here: fallback
does not work at all
from gulp-webserver.
In my case the fallback
was not set correctly. It does work.
from gulp-webserver.
Same issue here
from gulp-webserver.
@mickeyvip Can you post the correct configuration to the fallback
option, so that we can have a look and check on our side?
from gulp-webserver.
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var runSequence = require('run-sequence');
var env = 'dev';
gulp.task('clean:dev', function() {
return del(['.tmp']);
});
gulp.task('clean:dist', function() {
return del(['dist']);
});
gulp.task('scripts', function() {
var bundler = browserify('./app/scripts/app.js', {
extensions: ['.jsx'],
debug: env == 'dev'
}).transform('reactify');
return bundler.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('.tmp/scripts'));
});
gulp.task('imagemin', function() {
return gulp.src('app/images/*')
.pipe($.imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}]
}))
.pipe(gulp.dest('dist/images'));
});
gulp.task('copy', function() {
return gulp.src(['app/.txt', 'app/.ico'])
.pipe(gulp.dest('dist'));
})
gulp.task('bundle', function () {
var assets = $.useref.assets({searchPath: '{.tmp,app}'});
var jsFilter = $.filter(['/*.js']);
var cssFilter = $.filter(['/.css']);
var htmlFilter = $.filter(['.html']);
return gulp.src('app/*.html')
.pipe(assets)
.pipe(assets.restore())
.pipe($.useref())
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.autoprefixer({
browsers: ['last 5 versions']
}))
.pipe($.minifyCss())
.pipe(cssFilter.restore())
.pipe(htmlFilter)
.pipe($.htmlmin({collapseWhitespace: true}))
.pipe(htmlFilter.restore())
.pipe(
.pipe($.revReplace())
.pipe(gulp.dest('dist'))
.pipe($.size());
});
gulp.task('webserver', function() {
return gulp.src(['.tmp', 'app'])
.pipe($.webserver({
host: 'localhost', //change to 'localhost' to disable outside connections
livereload: true,
open: false,
fallback: 'index.html'
}));
});
gulp.task('serve', function() {
runSequence('clean:dev', ['scripts'], 'webserver');
gulp.watch('app/*.html');
gulp.watch('app/scripts/*/.js', ['scripts']);
gulp.watch('app/scripts/*/.jsx', ['scripts']);
});
gulp.task('build', function() {
env = 'prod';
runSequence(['clean:dev', 'clean:dist'],
['scripts', 'imagemin', 'copy'],
'bundle');
});
from gulp-webserver.
@vjunloc I was referring to @mickeyvip 's config, since I currently have the same issue and can't help much. But let's wait. maybe he sees it and posts it here.
P.S. I'd suggest you make use of markdown formatting when posting code in comments, since it helps a lot when it comes to readability.
from gulp-webserver.
hey @vjunloc I solved the problem on my side. It's not an issue with the gulp-webserver.
In my case it was related to relative
and absolute
paths. To be more specific, make sure your script and css references are absolute, so that it doesn't try to find them in the path you're typing in the URL.
e.g.:
You have two URLs: /settings
and /settings/account
. In that case, if you have your script inclusion in the fallback file being something like <script src="scripts/main.js"></script>
, the server will return a 404 for it, since there's no file in /settings/scripts/main.js
.
Hope that helps.
from gulp-webserver.
@alexandrethsilva , I am sorry for the late response.
Actually I don't remember what exactly was wrong. My friend explained it to me then and it made sense.
I think the problem was related to <base href="correct/path" />
from gulp-webserver.
@alexandrethsilva Thanks a lot for this. It was bugging me for the longest time.
from gulp-webserver.
Related Issues (20)
- Cache busted files not served to front-end
- GZip support
- Improve Documentation
- Livereload with HTTPS
- Error: EBUSY: resource busy or locked, stat 'C:\hiberfil.sys' at Error (native)
- Allow passing through connect-livereload rules
- Module 'proxy-middleware' is deprecated
- gulp command shows error on gitbash
- TypeError: res.send is not a function HOT 2
- Headers not added with configured middleware? HOT 1
- Is this project put in gulpjs plugins's blacklist?
- honor gulp --silent mode HOT 2
- Replace deprecated dependency gulp-util HOT 1
- How do I enable CORS?
- add request header using proxies and options
- critical vulnerability HOT 2
- Is this package still maintained? HOT 3
- Difference between gulp.src and path option? HOT 1
- Update to at least version 1.1.0 of tiny-lr to avoid Regular Expression Denial of Service
- replace isarray with Array.isArray
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-webserver.