function scripts() {
return src(['app/js/*.js', '!app/js/*.min.js'])
.pipe(webpackStream({
mode: 'production',
performance: { hints: false },
plugins: [
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery' }), // jQuery (npm i jquery)
],
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['babel-plugin-root-import']
}
}
}
]
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: { format: { comments: false } },
extractComments: false
})
]
},
}, webpack)).on('error', function handleError() {
this.emit('end')
})
.pipe(concat('app.min.js'))
.pipe(dest('app/js'))
.pipe(browserSync.stream())
}
const plumber = require('gulp-plumber');
function html() {
return src(path.src.html, {base: 'src/'})
.pipe(plumber())
.pipe(pug({pretty: true}))
.pipe(dest(path.build.html))
.pipe(browsersync.stream())
}
import plumber from 'gulp-plumber';
// or
// const plumber = require('gulp-plumber');
function scripts() {
return src(['app/js/*.js', '!app/js/*.min.js'])
.pipe(plumber())
.pipe(webpackStream({
mode: 'production',
performance: { hints: false },
plugins: [
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery' }), // jQuery (npm i jquery)
],
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['babel-plugin-root-import']
}
}
}
]
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: { format: { comments: false } },
extractComments: false
})
]
},
}, webpack)).on('error', function handleError() {
this.emit('end')
})
.pipe(concat('app.min.js'))
.pipe(dest('app/js'))
.pipe(browserSync.stream())
}