Skip to content

Feature/32702 #247

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

Merged
merged 15 commits into from
Dec 18, 2018
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ rules:
- 'stroustrup'
-
allowSingleLine: false
one-var: 0
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ You will find sample config files for theses plugins in `vendor/snowdog/frontool
* `--theme name` - Process single theme.
* `--disableLinting` - Disable SASS and CSS linting.
* `--disableMaps` - Disable inline source maps generation.
* `email-fix` - Fixes email stylesheet for Magento < 2.3.0. [Related issue](https://github.com/MyIntervals/emogrifier/issues/296)
* `--prod` - Production output - minifies styles and add `.min` sufix.
* `eslint` - Watch and run [eslint](https://github.com/adametry/gulp-eslint) on specified JS file.
* `--file fileName` - You have to specify what file you want to lint, fileName without .js.
* `inheritance` - Create necessary symlinks to resolve theme styles inheritance and make the base for styles processing. You have to run in before styles compilation and after adding new files.
Expand Down
22 changes: 22 additions & 0 deletions helper/email-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'
module.exports = (gulp, plugins, config, name) => {
const production = plugins.util.env.prod || false
const theme = config.themes[name]
const srcBase = config.projectPath + theme.dest
const emailFilename = production ? 'email-inline.min.css' : 'email-inline.css'

return gulp.src(srcBase + '/**/*/' + emailFilename, { base: './' })
.pipe(plugins.if(
!plugins.util.env.ci,
plugins.plumber({
errorHandler: plugins.notify.onError('Error: <%= error.message %>')
})
))
.pipe(plugins.logger({
display : 'rel',
beforeEach: 'Email styles from: ',
afterEach: ' has been fixed!'
}))
.pipe(plugins.replace('@charset "UTF-8";', ''))
.pipe(gulp.dest('./'))
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"gulp-plumber": "~1.2.0",
"gulp-postcss": "~7.0.1",
"gulp-rename": "~1.2.2",
"gulp-replace": "^0.6.1",
"gulp-rimraf": "~0.2.2",
"gulp-sass": "~3.2.1",
"gulp-sass-error": "~1.0.5",
Expand All @@ -57,6 +58,7 @@
"csslint": "gulp csslint",
"default": "gulp",
"dev": "gulp dev",
"email-fix": "gulp email-fix",
"eslint": "gulp eslint",
"inheritance": "gulp inheritance",
"sasslint": "gulp sasslint",
Expand Down
21 changes: 21 additions & 0 deletions task/email-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'
module.exports = () => {
// Global variables
const gulp = this.gulp
const plugins = this.opts.plugins
const config = this.opts.configs
const themes = plugins.getThemes()
const streams = plugins.mergeStream()
const emailFix = require('../helper/email-fix')

themes.forEach(name => {
plugins.util.log(
plugins.util.colors.green('Runing email-fix on') + ' '
+ plugins.util.colors.blue(name) + ' '
+ plugins.util.colors.green('theme...')
)
streams.add(emailFix(gulp, plugins, config, name))
})

return streams
}
Loading