Browse Source

Pass {base} argument to gulp bundler.

test-gpt-generated
Roman Axelrod 3 years ago
parent
commit
6ebd37190a
  1. 16
      server.js

16
server.js

@ -221,7 +221,7 @@ function startBrowserSync() {
return cb();
}]));
gulp.watch(getPathFiles(projectPath, "src/**/*.scss"), {delay: 400}, gulp.series(['build-styling-files', function (cb) {
gulp.watch(path.posix.join(projectPath, "src/**/*.scss"), {delay: 400}, gulp.series(['build-styling-files', function (cb) {
browserSyncReload(bs, 'css', 'Style Files Change');
return cb();
}]));
@ -275,12 +275,12 @@ function browserSyncReload(bs, extension = '', message = '') {
}
function getJSBundleFiles() {
return [getPathFiles(projectPath, "src/**/*.js"), getPathFiles(projectPath, "src/**/*.mjs"), "!" + getPathFiles(projectPath, "src/**/*.min.js")];
return [path.posix.join(projectPath, "src/**/*.js"), path.posix.join(projectPath, "src/**/*.mjs"), "!" + path.posix.join(projectPath, "src/**/*.min.js")];
}
function buildScriptFiles(done) {
const files = getJSBundleFiles();
return gulp.src(files)
return gulp.src(files, {base: path.posix.join(projectPath, 'src')})
.pipe(sourcemaps.init({}))
.pipe(babel()).on('error', function (error) {
showError(new PluginError('JavaScript', error).toString());
@ -291,11 +291,11 @@ function buildScriptFiles(done) {
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(getPathFiles(projectPath, 'src')));
.pipe(gulp.dest(path.posix.join(projectPath, 'src')));
}
function buildStyleFiles(done) {
return gulp.src(path.join(projectPath, 'src/**/*.scss'))
return gulp.src(path.join(projectPath, 'src/**/*.scss'), {base: path.posix.join(projectPath, 'src')})
.pipe(sourcemaps.init({}))
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', function (error) {
showError(new PluginError('SCSS', error.messageFormatted).toString());
@ -305,7 +305,7 @@ function buildStyleFiles(done) {
// .pipe(gulp.dest('src/'))
.pipe(rename({extname: '.min.css'}))
.pipe(sourcemaps.write('.', {}))
.pipe(gulp.dest(getPathFiles(projectPath, 'src')))
.pipe(gulp.dest(path.posix.join(projectPath, 'src')))
}
function buildAssetFiles() {
@ -412,7 +412,3 @@ console.log('Configs', {
developmentBlockName
});
console.log('\n----------------------------------\n')
function getPathFiles(...paths) {
return path.join(...paths).replace(/\\\\/g, '/');
}

Loading…
Cancel
Save