Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Divi additional 12000+ CSS lines #77

Merged
merged 10 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const rename = require( 'gulp-rename' );
const sass = require( 'gulp-sass' )( require( 'sass' ) );
const uglify = require( 'gulp-uglify-es' ).default;
const browserSync = require( 'browser-sync' ).create();
const replace = require( 'gulp-replace' );
const merge = require( 'merge-stream' );

/**
* Get Package File
Expand Down Expand Up @@ -68,6 +70,16 @@ const library = {
watch: {}
};

/**
* Generate multiple styles with different prefixes.
*
* @since 1.12.17
*/
const builders = [
{ name: '', prefix: '' }, // for default styles
{ name: 'divi', prefix: '.et-db #et-boc .et_pb_module' } // for divi builder
];

library.source.main = './library/';
library.source.fonts = './library/fonts/';
library.source.scripts = './library/js/';
Expand Down Expand Up @@ -245,24 +257,27 @@ gulp.task( 'library:fonts', function() {

// Build styles
gulp.task( 'library:styles', function() {

return gulp.src( library.watch.styles )
.pipe(
sass({ outputStyle: 'compressed' })
.on( 'error', sass.logError )
)
.pipe( autoprefixer( browsersList ) )
.pipe( header( banner ) )
.pipe( cleanCSS() )
.pipe( rename({
suffix: '.min'
}) )
.pipe( gulp.dest( library.output.styles ) )
.pipe( gulp.dest( showcase.output.styles ) )
.pipe( browserSync.stream({
match: '**/*.css'
}) )
;
const tasks = builders.map( config => {
return gulp.src( library.watch.styles )
.pipe(
sass({ outputStyle: 'compressed' })
.on( 'error', sass.logError )
)
.pipe( replace( '__PREFIX__', config.prefix ) )
.pipe( autoprefixer( browsersList ) )
.pipe( header( banner ) )
.pipe( cleanCSS() )
.pipe( rename({
suffix: '' !== config.name ? `.builder_${config.name}.min` : '.min'
}) )
.pipe( gulp.dest( library.output.styles ) )
.pipe( gulp.dest( showcase.output.styles ) )
.pipe( browserSync.stream({
match: '**/*.css'
}) );
});

return merge( tasks ); // Merge all streams and return them
});

// Build scripts
Expand Down
6 changes: 2 additions & 4 deletions library/scss/mixins/_body-class.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

@mixin body-class($module-type: all, $module-theme: all, $desktop: false) {

.forminator-ui,
.et-db #et-boc .et_pb_module .forminator-ui {
__PREFIX__ .forminator-ui {

@if ($module-type == all) {

Expand Down Expand Up @@ -145,8 +144,7 @@
// =============================================
@mixin form-class($module-type: no-type, $module-theme: no-theme, $desktop: false) {

.forminator-ui,
.et-db #et-boc .et_pb_module .forminator-ui {
__PREFIX__ .forminator-ui {

@if ($module-type == no-type) {

Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"gulp-uglify": "^3.0.1",
"gulp-uglify-es": "^3.0.0",
"gulp-watch": "^4.0.1",
"merge-stream": "^2.0.0",
"pump": "^3.0.0",
"sass": "^1.63.6"
},
Expand Down