Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run (files) {
// Create javascript array
let entries = glob.sync(files);
// Browserfiy javascript
return browserify({
'entries' : entries,
'paths' : [
'./',
'./app/bundles',
'./lib/bundles',
'./node_modules'
]
})
.transform(babelify)
.bundle()
.pipe(source('sw.js'))
.pipe(buffer())
.pipe(sourcemaps.init({
const configurePurgeCss = () => {
let paths = [];
// Configure whitelist paths
for (const [key, value] of Object.entries(settings.purgeCssConfig.paths)) {
paths.push(path.join(__dirname, value));
}
return {
paths: glob.sync(paths),
whitelist: WhitelisterPlugin(settings.purgeCssConfig.whitelist),
whitelistPatterns: settings.purgeCssConfig.whitelistPatterns,
extractors: [
{
extractor: TailwindExtractor,
extensions: settings.purgeCssConfig.extensions
}
]
};
};
...{ROUTER_MODE: `"${routerMode}"`},
...{TITLE: `"${networkConfig.title}"`}
},
GIT_VERSION: JSON.stringify(gitRevision.version),
GIT_DATE: JSON.stringify(gitRevision.date)
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: utils.assetsPath('css/[name].[contenthash].css'),
chunkFilename: '[id].css'
}),
// Remove unused CSS using purgecss. See https://github.com/FullHuman/purgecss
// for more information about purgecss.
new PurgecssPlugin({
paths: glob.sync([
path.join(__dirname, './../index.html'),
path.join(__dirname, './../**/*.vue'),
path.join(__dirname, './../src/**/*.js')
]),
whitelist: [
'border-theme-page-background',
'table-component__th--sort-asc', 'table-component__th--sort-desc',
'tooltip', 'tooltip-inner', 'tooltip-arrow',
'tr', 'td',
'v-spinner'
],
whitelistPatterns: [
/^tooltip-bg-/
],
extractors: [{
extractor: TailwindExtractor,
load(id) {
if (id === options.id) {
// Pass in relative filepaths to glob, then convert to appropriate URLs
const files = glob.sync(options.patterns)
.map(file => file.replace('public/', '/'));
return `export default ${JSON.stringify(files)};`;
}
}
}
module.exports = function(hot, dev) {
var config = {
entry: glob.sync(testGlob),
output: {
path: path.resolve(__dirname, '..', 'wwwroot', 'build'),
filename: 'TerriaJS-specs.js',
publicPath: 'build/'
},
devtool: 'source-map',
module: {
loaders: [
{
// Don't let jasmine-ajax detect require and import jasmine-core, because we bring
// in Jasmine via a script tag instead.
test: require.resolve('terriajs-jasmine-ajax'),
loader: 'imports-loader?require=>false'
}
]
},
function fileList(sourceDir, ignoreList, callback) {
// Set pattern
var patterns = ['**/*.*'];
lodash.forEach(ignoreList, function(item) {
patterns.push('!'+path.normalize(item));
});
// Glob the files
var files = glob.sync(patterns, {
cwd: path.resolve(process.cwd(), sourceDir),
});
// Filter file only
files = lodash.filter(files, function(item) {
var filePath = path.resolve(process.cwd(), sourceDir+'/'+item);
if (!fs.existsSync(filePath)) {
return false;
}
return fs.lstatSync(filePath).isFile();
});
return callback(files);
}
return BbPromise.each(assets.files, (opt) => {
this.log(`Sync bucket: ${bucket}:${prefix}`);
this.log(`Path: ${opt.source}`);
const cfg = Object.assign({}, globOpts, { cwd: opt.source });
const filenames = glob.sync(opt.globs, cfg);
return BbPromise.each(filenames, (filename) => {
const body = fs.readFileSync(path.join(opt.source, filename));
const type = mime.lookup(filename) || opt.defaultContentType || 'application/octet-stream';
this.log(`\tFile: ${filename} (${type})`);
// when using windows path join resolves to backslashes, but s3 is expecting a slash
// therefore replace all backslashes with slashes
const key = path
.join(prefix, filename)
.replace(/\\/g, '/');
const details = Object.assign(
{
ACL: assets.acl || 'private',
Body: body,
watchSequence(name, patterns, sequence) {
__.activeGuards[name] = 0;
__.ignoredChanges[name] = 0;
// Can't trust chokidar to do globbing
const files = globAll.sync(patterns);
return gulp.watch(files, { queue: false }, gulp.series(sequence, (callback) => {
// Log watcher as completed
logGuard(END, name);
__.activeGuards[name] = 0;
__.ignoredChanges[name] = 0;
// When there is no more running watchers
let anyGuardLeft = false;
Object.keys(__.activeGuards).forEach((key) => {
if (__.activeGuards[key]) {
anyGuardLeft = true;
}
});
mochaInterface.describe(contextName, function () {
globAll.sync(patterns).forEach(function (file) {
test(file, options);
});
});
};
'@': path.resolve(__dirname, 'assets')
}
},
};
if (isRelease) {
module.exports.plugins.push(new Manifest('manifest.json'));
module.exports.plugins.push(
new WebpackCleanPlugin({
on: "emit",
path: ['./dist']
}));
module.exports.plugins.push(new PurifyCSSPlugin({
paths: glob_all.sync([
path.join(__dirname, '**/*.php'),
path.join(__dirname, 'assets/js/**/*.js'),
path.join(__dirname, 'assets/vue/**/*.vue'),
path.join(__dirname, 'node_modules/simplebar/**/*.js'),
]),
whitelist: [
'rtl',
'ltr'
],
}));
}