PostCSS plugin Process css for AMP for twig. Create css for AMP to using with twig template.
/* before */
.thumb {
background-image: url(../images/thumb.png);
}
/* after */
.thumb {
background-image: url({{ your_static_path|raw }}/images/thumb.png);
}
/* or */
.thumb {
background-image: url(http://sample.com/images/thumb.png);
}
To avoid an error with '{#' (twig start comment) or '%}' (just for sure)
/* before */
@media (max-width:991px){#header{height:100px}#footer{height:50%}}
/* after */
@media (max-width:991px){ #header{height:100px}#footer{height:50% }}
Add PostCSS Amp Process to your build tool:
npm install postcss-amp-process --save-dev
Load PostCSS Amp Process as a PostCSS plugin:
postcss([
require('postcss-amp-process')({
/* options */
}),
]);
You can define your own array strings replace
require('postcss-unmq')({
replace: [['find', 'replace'], [/\.\.\//g, '{{ your_static_path|raw }}/']],
});