shunter
shunter copied to clipboard
rm Mincer
Mincer appears to be no longer actively maintained.
Looks like we should remove this dependency of shunters, ideally providing an upgrade path. Suggestions? :)
As we want to replace Mincer without introducing breaking changes, @moddular & I had a think about functionality we need to reimplement;
- Inheritance: Shunter does it for templates, Mincer for assets. Used in the asset path helpers.
- Local dev asset server -- Mincer
- Compile assets -- Mincer
- Template asset path helper
@assetPath
-- dust, looks up against the mincerenvironment
backed by asset manifest JSON -
*= require foo.css
-- Mincer directive. Smells like a custom processor thing we need to write. - CSS & JS asset path helper
<%= asset_path
-- parsed by EJS. Uses same mechanism as previous point under the bonnet. Smells like a custom processor thing we need to write.
Other stuff;
- EJS -- probably not needed any more, superceded by Mincer anyway. Removing it I guess would be breaking.
- Asset manifest: maps local files to prod MD5 filenames, useful for the asset path helpers (npm's
webpack-asset-pipeline
) - Should use all the default shunter dirs
- Maybe a feature toggle for EJS,
*= require foo.css
&<%= asset_path
functionality...
I was looking at webpack as it can compile the assets, resolve includes and amend hash to files.
First hurdle was making sure the assets are resolved locally first then in mosaic. I was able to achieve this:
resolve: {
modules: [
'resources/fonts',
'resources/img',
'resources/css',
'resources/js',
'node_modules/shunter-mosaic/resources/fonts',
'node_modules/shunter-mosaic/resources/img',
'node_modules/shunter-mosaic/resources/css',
'node_modules/shunter-mosaic/resources/js',
'node_modules'
],
extensions: [".js.ejs", ".js", ".css.ejs", ".css"]
}
Next I remembered after some trail and error to include JS files in the bundle you should use module.exports = function() {}
which is a bit of a problem.. unless we change all of the mosaic JS files.
Then I was looking into the CSS and found out even if I can replace all of the mincer //= require
snippets with @import
, which I was able to through a skeleton loader. I cannot do the same for the imported CSS.. So that is a problem I am looking into.
I know mosaic uses SASS so I would like to find out how the SASS config is setup.
We've just been chatting about this in FED leadership and are coming round to the idea of making this a breaking change, whilst maintaining a "bugfix only" branch of Mincery shunter. Upgrading should not involve too much more than changing the CSS to use @import
over require
, the JS will need some minor rewriting, as Michael mentioned.
Due to;
- less code complexity in shunter
- forces Shunter upgrade on teams
- prob less effort (for us) to rewrite our code to ditch EJS stuff than to maintain this tricky half-way house
- probably is going to be quicker and less complex to just upgrade client applications
@jpw did you get any further with this? We can see mincer is now referencing a vulnerable version on lodash
- I'm more than happy to provide developer time for this update if needed? Will just need a steer from your side?
Realistically this is not going to happen, but on the upside it's not hard to work around Mincer and use alternatives.