0

I fail to set up LessCss filter with asset_compress plugin on a new CakePHP4 app. Read the docs: https://github.com/markstory/asset_compress/wiki There are some examples on js filters and config in general, so I set up mine like so:

[General]
cacheConfig = false

[js]
cachePath = WEBROOT/cache_js/

[css]
cachePath = WEBROOT/cache_css/

[less]
filters[] = LessCss

[app-v1.css]
files[] = WEBROOT/less/app-v1.less

What happens is app-v1.less get parsed like a css file, so all the Less stuff is still there and not processed properly. When adding filters[] = LessCss to [css] or [app-v1.css] get an error:

Error: /usr/local/lib/node_modules/less/dist/less.cjs.js:6735
            imports.contents[fileInfo.filename] = str;
                   ^

TypeError: Cannot read property 'contents' of undefined
    at Object.parse (/usr/local/lib/node_modules/less/dist/less.cjs.js:6735:20)
    at Object.<anonymous> (/Users/yy/www/fudis_app/tmp/asset_compress_less6IDAL9:5:8)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)

I understand this is a general question and possibly I am missing something in the docs or general understanding, but a simple example of a proper config would be really handy. Thanks!

Yevgeniy
  • 300
  • 2
  • 7
  • For frontend development use frontend dev tools like webpack, grunt, etc. – Salines Feb 19 '20 at 10:48
  • thanks for the tip @Salines, I do wish to use asset_compress plugin though – Yevgeniy Feb 19 '20 at 18:19
  • @Salines I see you're an experience CakePHP developer, yet you suggest using webpack and grunt, can you may be elaborate why these tools are better than asset_compress plugin? Thanks! – Yevgeniy Feb 20 '20 at 05:59
  • Grunt, webpack and friends are powerful tools developed for frontend development. It is desirable to separate the backend of frontend development. Every frontend developer knows javascript, but he certainly doesn't know all the backend languages. – Salines Feb 20 '20 at 09:02

0 Answers0