Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
externals: [/^[-/a-zA-Z0-9]+$/, /^@babel\/.+$/],
target: opts.target,
node: {
fs: 'empty',
net: 'empty',
path: 'empty',
child_process: 'empty',
util: 'empty',
},
output: {
filename: filename,
libraryTarget: opts.libraryTarget,
library: opts.libraryName,
},
plugins: [
new webpackStream.webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(
isProduction ? 'production' : 'development',
),
}),
new webpackStream.webpack.optimize.OccurrenceOrderPlugin(),
],
};
if (isProduction && !opts.noMinify) {
// See more chunks configuration here: https://gist.github.com/sokra/1522d586b8e5c0f5072d7565c2bee693
webpackOpts.optimization = {
minimize: true,
};
}
return webpackStream(webpackOpts, webpack, function(err, stats) {
if (err) {
throw new gulpUtil.PluginError('webpack', err);
'fs': 'empty'
},
output: {
// The output filename
filename: PROD ? 'jbb.min.js' : 'jbb.js',
// Export itself to a global var
libraryTarget: 'var',
// Name of the global var: 'JBB.BinaryLoader'
library: [ 'JBB', 'BinaryLoader' ]
},
externals: {
'three': 'THREE',
},
plugins: ([
new webpack.webpack.optimize.DedupePlugin(),
new webpack.webpack.DefinePlugin({
GULP_BUILD : PROD
})
]).concat(PROD ? [
new webpack.webpack.optimize.UglifyJsPlugin({
minimize: true
})
] : [])
}))
.pipe(header("/* JBB Binary Bundle Loader - https://github.com/wavesoft/jbb */\n"))
.pipe(gulp.dest('dist'));
});
.pipe(plumber())
.pipe(webpack({
output: {
filename: 'build.js',
pathinfo: true,
sourcePrefix: '\t\t\t'
},
resolve: {
root: path.join(__dirname, 'app', 'js')
},
devtool: 'source-map',
plugins: [
// fix compilation persistence
new webpack.webpack.optimize.OccurenceOrderPlugin(true),
// global constants
new webpack.webpack.DefinePlugin({
DEBUG: false
})
]
}, null/*, report*/))
.pipe(gulp.dest('tests'));
});
.src(path.join(global.paths.app, 'js', 'main.js'))
.pipe(plumber())
.pipe(webpack({
output: {
filename: 'release.js'
},
resolve: {
extensions:['', '.js']
},
debug: false,
cache: false,
plugins: [
// fix compilation persistence
new webpack.webpack.optimize.OccurenceOrderPlugin(true),
// global constants
new webpack.webpack.DefinePlugin({
DEBUG: false
}),
// obfuscation
new webpack.webpack.optimize.UglifyJsPlugin({
// this option prevents name changing
// use in case of strange errors
// mangle: false,
output: {
comments: false
},
/*eslint camelcase:0 */
compress: {
warnings: true,
unused: true,
dead_code: true,
drop_console: true,
test: /\.html$/,
use: {
loader: 'dust-loader'
}
}
]
},
mode: $.util.env.production ? 'production' : 'development',
optimization: {
minimize: $.util.env.production ? true : false,
},
plugins: [
new webpack.webpack.DefinePlugin({
VERSION: JSON.stringify(_.pkg.version)
}),
new webpack.webpack.BannerPlugin('Build Version: ' + _.pkg.version),
$.util.env.production ? $.util.noop : new HardSourceWebpackPlugin()
],
devtool: $.util.env.production ? '' : 'eval-source-map'
}))
.pipe($.preprocess(_.preprocessContext))
.pipe((_.isProdEnv()) ? gulp.dest(_.paths.dest.default) : gulp.dest(_.paths.dest.files))
.pipe($.filter(f => /checkout/.test(f.path)))
.pipe($.rename(file => file.basename = file.basename.replace('.min', '')))
.pipe(gulp.dest(_.paths.dest.files));
};
/**
* Bundles JS source files via Webpack.
*
* Example Usage:
* gulp scripts
* gulp scripts --is-production
*/
import gulp from 'gulp';
import {argv as args} from 'yargs';
import globalSettings from '../../config';
import BrowserSyncPlugin from 'browser-sync-webpack-plugin';
import webpackStream from 'webpack-stream';
let webpack = webpackStream.webpack;
/**
* Wrapper task that calls the webpack-stream package with
* configuration and outputs bundles.
*
* @return {Object} - Stream.
*/
gulp.task('scripts', () => {
return _runWebpack();
});
/**
* Wrapper task that calls the webpack-stream package with
* configuration and outputs bundles. This variation will
* pass through an option which turns on watch mode.
*
{
test: /.js?$/,
loader: 'babel-loader',
query: {
presets: ['es2015'],
plugins: ['transform-object-assign']
}
}
]
},
resolve: {
modulesDirectories: ['node_modules', 'bower_components'],
extensions: ['', '.js', '.jsx']
},
plugins: [
new webpack.webpack.ProvidePlugin({
Promise: 'es6-promise-promise'
})
]
};
gulp.task('clean', () => {
['dist','temp','temp/screenshots'].map((dir)=>{
fs.removeSync(dir);
fs.mkdirSync(dir);
});
});
gulp.task('test', ['make'], function () {
const buildDist = function(opts) {
const webpackOpts = {
externals: {},
output: {
filename: opts.output,
libraryTarget: 'umd',
library: 'fbt',
},
plugins: [
new webpackStream.webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(
opts.debug ? 'development' : 'production',
),
}),
new webpackStream.webpack.LoaderOptionsPlugin({
debug: opts.debug,
}),
],
optimization: {
minimize: !opts.debug,
},
};
if (!opts.debug) {
webpackOpts.plugins.push(new UglifyJsPlugin());
}
return webpackStream(webpackOpts, null, function(err, stats) {
if (err) {
throw new gulpUtil.PluginError('webpack', err);
}
var buildDist = function(opts) {
var webpackOpts = {
debug: opts.debug,
externals: {
react: 'React',
},
module: {
loaders: [{test: /\.js$/, loader: 'babel'}],
},
output: {
filename: opts.output,
library: 'Animated',
},
plugins: [
new webpackStream.webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(
opts.debug ? 'development' : 'production',
),
}),
new webpackStream.webpack.optimize.OccurenceOrderPlugin(),
new webpackStream.webpack.optimize.DedupePlugin(),
],
};
if (!opts.debug) {
webpackOpts.plugins.push(
new webpackStream.webpack.optimize.UglifyJsPlugin({
compress: {
hoist_vars: true,
screw_ie8: true,
warnings: false,
},
const buildDist = (opts) => {
const webpackOpts = {
debug: opts.debug,
externals: {
React: 'React',
'draft-js': 'Draft'
},
output: {
filename: opts.output,
libraryTarget: 'var',
library: 'DraftTypeahead'
},
plugins: [
new webpackStream.webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(
opts.debug ? 'development' : 'production'
)
}),
new webpackStream.webpack.optimize.OccurenceOrderPlugin(),
new webpackStream.webpack.optimize.DedupePlugin()
]
};
if (!opts.debug) {
webpackOpts.plugins.push(
new webpackStream.webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true
}
})
);