Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
];
// Source any JS for allowed modules, which will minimize us shipping much
// more JS that we haven't pointed to in PHP yet.
// Example output: modules/(shortcodes|widgets)/**/*.js
const supportedModulesSource = `modules/@(${ supportedModules.join( '|' ) })/**/*.js`;
// Uglify other JS from _inc and supported modules
const sources = [ '_inc/*.js', supportedModulesSource, '!modules/**/test-*.js' ];
// Don't process minified JS in _inc or modules directories
const sourceNegations = [ '!_inc/*.min.js', '!modules/**/*.min.js' ];
gulp
.src( [ ...sources, ...sourceNegations ] )
.pipe(
prepend.prependText(
'/* Do not modify this file directly. It is compiled from other files. */\n'
)
)
.pipe( gulpif( ! is_prod, sourcemaps.init() ) )
.pipe(
minify( {
output: {
comments: saveLicense,
},
noSource: true,
ext: { min: '.js' },
} )
)
.pipe( rename( { suffix: '.min' } ) )
.pipe( gulpif( ! is_prod, sourcemaps.write( 'maps' ) ) ) // Put the maps in _inc/build/maps so that we can easily .svnignore
.pipe( gulp.dest( '_inc/build' ) )
gulp.task('rtl:style_uni', function () {
return gulp.src(config.src.styles.style_uni)
.pipe(gap.prependText('@import "./rtl.scss";\n')) // watch out for this relative path!
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(prefix('last 1 version'))
.pipe(gap.prependText(autoGeneratedHeader))
.pipe(gulpif(!config.dev, csso()))
.pipe(gulpif(!config.dev, sourcemaps.write()))
.pipe(rename({ prefix: "rtl_" }))
.pipe(gulp.dest(config.dest.themes))
.pipe(gulpif(config.dev && config.build, gulp.dest(config.dest.themes)))
.pipe(gulpif(config.dev, reload({ stream: true })));
})
gulp.task("build-browser-min", function () {
// Minified browser build
return typescriptToJavascript()
.pipe(sourcemaps.init())
.pipe(preprocess({
context: { NODEJS: false }
}))
.pipe(uglify({
wrap: "google_myanmar_tools"
}))
.pipe(prependText(LICENSE, "\n"))
.pipe(rename({
extname: ".min.js"
}))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("build_browser"));
});
];
// Source any JS for whitelisted modules, which will minimize us shipping much
// more JS that we haven't pointed to in PHP yet.
// Example output: modules/(shortcodes|widgets)/**/*.js
const supportedModulesSource = `modules/@(${ supportedModules.join( '|' ) })/**/*.js`;
// Uglify other JS from _inc and supported modules
const sources = [ '_inc/*.js', supportedModulesSource, '!modules/**/test-*.js' ];
// Don't process minified JS in _inc or modules directories
const sourceNegations = [ '!_inc/*.min.js', '!modules/**/*.min.js' ];
gulp
.src( [ ...sources, ...sourceNegations ] )
.pipe(
prepend.prependText(
'/* Do not modify this file directly. It is compiled from other files. */\n'
)
)
.pipe( gulpif( ! is_prod, sourcemaps.init() ) )
.pipe(
minify( {
output: {
comments: saveLicense,
},
noSource: true,
ext: { min: '.js' },
} )
)
.pipe( rename( { suffix: '.min' } ) )
.pipe( gulpif( ! is_prod, sourcemaps.write( 'maps' ) ) ) // Put the maps in _inc/build/maps so that we can easily .svnignore
.pipe( gulp.dest( '_inc/build' ) )
gulp.task( 'sass:instant-search', function ( done ) {
log( 'Building Instant Search CSS bundle...' );
return gulp
.src( './modules/search/instant-search/*.scss' )
.pipe( sass( { outputStyle: 'compressed' } ) )
.pipe(
prepend.prependText( '/* Do not modify this file directly. It is compiled SASS code. */\n' )
)
.pipe( autoprefixer() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( gulp.dest( './_inc/build/instant-search' ) )
.on( 'end', function () {
log( 'Instant Search CSS finished.' );
done();
} );
} );
gulp.series( 'sass:packages', function () {
return (
gulp
.src(
[
'packages/**/assets/*.css',
'!packages/**/assets/*min.css',
'!packages/**/assets/*rtl.css',
],
{ base: '.' }
)
.pipe(
prepend.prependText(
'/*!\n' +
'* Do not modify this file directly. It is automatically generated.\n' +
'*/\n'
)
)
.pipe( autoprefixer() )
// Build *-rtl.css
.pipe( rtlcss() )
.pipe( rename( { suffix: '-rtl' } ) )
.pipe( gulp.dest( '.' ) )
// Build *-rtl.min.css
.pipe( cleanCSS() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( gulp.dest( '.' ) )
// Finished
.on( 'end', function () {
replace(/^(.+):/gm, "\n$1:"),
// Replace heading marks.
replace(/=== (.+) ===/g, "# $1 #"),
replace(/== (.+) ==/g, "## $1 ##"),
replace(/= (.+) =/g, "### $1 ###"),
// Link the contributors.
replace(
"Contributors: tivnetinc, alexgff, tivnet",
"Contributors: [TIV.NET INC.](https://profiles.wordpress.org/tivnetinc), " +
"[Alex Gor](https://profiles.wordpress.org/alexgff), " +
"[Gregory Karpinsky](https://profiles.wordpress.org/tivnet)"),
// Prepend badges.
prepend.prependText(badges),
rename("README.md"),
dest("."),
print()
],
cb
);
};
gulp.task('vendorDraftJsCss', function () {
return gulp
.src([`${draftJsDist}/Draft.css`])
.pipe(gap.prependText('::ng-deep { '))
.pipe(gap.prependText('/* This file is automatically generated from Draft.css upstream */'))
.pipe(gap.prependText('/* Do not edit */'))
.pipe(gap.appendText(' }'))
.pipe(compileSass())
.pipe(rename('draft-js.component.css'))
.pipe(gulp.dest(`${src}/${lib}`));
});
gulp.task("licenses", async function() {
// this is to add Creative Tim licenses in the production & dev mode for the minified js
gulp.src(["dist/js/chunk-vendors*.js", "dist/js/app*.js"], { base: "./" })
.pipe(gap.prependText(product_copyright_template))
.pipe(gulp.dest("./", { overwrite: true }));
// this is to add Creative Tim licenses in the production & dev mode for the minified html
gulp.src("dist/index.html", { base: "./" })
.pipe(gap.prependText(product_copyright_template))
.pipe(gulp.dest("./", { overwrite: true }));
// this is to add Creative Tim licenses in the production & dev mode for the minified css
gulp.src(["dist/css/chunk-vendors*.css", "dist/app*.css"], { base: "./" })
.pipe(gap.prependText(product_copyright_template))
.pipe(gulp.dest("./", { overwrite: true }));
return;
});
function testsBuild() {
// Combine js files and append tests
return gulp.src(getPaths().map(function(f) { return 'site/public/' + f; })) // Get rid of prepend
.pipe(concat('tests/index.js'))
.pipe(gap.prependFile('tests/prepend.js'))
.pipe(gap.appendText('start();'))
.pipe(addsrc.append(getTestPaths().map(function (f) { return 'tests/public/' + f; })))
.pipe(concat('tests/index.js'))
.pipe(gulp.dest('.'));
}