How to Style Email Template in Magento2

emailmagento2

How to style email template? I want to override email variable value and change style according without element inline style used. Is there possible to complie email's less files with grunt.

How to compile email style?

Best Answer

Please follow below step to compile email.less

  1. copy _email-extend.less folder from vendor/magento/theme-frontend-blank/web/css/source/_email-extend.less and put under app/design/frontend/vendor(packagename)/your-theme(custom theme)/web/css/source/

  2. open root/dev/tools/grunt/configs/theme.js and put following code in it (configure your theme in theme.js)

    theme: {
    area: 'frontend',
    name: 'vendor/your-theme',
    locale: 'en_US',
    files: [
        'css/styles-m',
        'css/styles-l',
        'css/email',
        'css/email-inline',            

    ],
    dsl: 'less'
  1. Clean root/var/ and pub/static folder.
  2. Run grunt exec:theme (your-theme)
  3. Run php bin/magento setup:static-content:deploy
  4. Run grunt watch:theme (your-theme)
  5. Modify "_email-extend.less", now it is compile through grunt.
Related Topic