-
Notifications
You must be signed in to change notification settings - Fork 54
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
EJS relation + bundling #773
Comments
Yes, correct :). AssetGraph also interops with webpack in case you'd still like to use it for bundling your JavaScript.
Hmm, I think you'll need to make sure that .ejs is interpreted as HTML, which is supposed to support the As an initial attempt, you can try: require('AssetGraph').Html.prototype.supportedExtensions.push('.ejs');
How exactly is it including those files? That sounds like a non-standard relation type, which would have to be added outside of the core framework, and that isn't supported right now. Trying to get it into AssetGraph 4.0.0, stay tuned :) Does this tool is appropriate to bundling my web site. Ideally I would like to :
It's very suited to all of the above, with the possible exception of "Include only used javascript". What do you mean by that? Should it exclude dead code from the included files, or should it just ignore other files that might reside on disk, but aren't explicitly included? |
Hi @papandreou, thank you for taking 2 minutes to answer me.
I prefer not to use Webpack anyway. I have already wasted too much time (2-3 week) trying to get Webpack working with multiple html/ejs file as entries. extract-text-webpack-plugin htmlwebpackplugin, etc................. there always someting that required a new pluging, and a new one, and a new one and finally you get something that does not work. Maybe it's wonderful for javascript main entry but it is a mess for my needs.
I rename the ejs file to html file and do a small test. The file is loading but I did not test if tag
I will give a try tomorrow, than you.
Here is an example : header.ejs<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
...
</head> footer.ejs ...
<% /* jQuery */ %>
<script src="/public/vendors/jquery/dist/jquery.min.js"></script>
<% /* jQuery Validate */ %>
<script src="/public/vendors/jquery-validation/dist/jquery.validate.min.js"></script>
<% /* Bootstrap */ %>
<script src="/public/vendors/bootstrap/dist/js/bootstrap.min.js"></script> home.ejs <% /* Here I include the partial header section */ %>
<%- include('header') -%>
<body class="nav-md">
<div class="container body">
<div class="main_container">
...
<% /* Here I include the partial footer section */ %>
<%- include('footer') -%>
</body>
</html> This partial section are useful to prevent repeating it each page (ejs). Instead we include it and we have only one instance to maintain. If AssetGraph is not supporting it, maybe I could create a pre-AssetGraph task to merge all partial section into their respective page and copy those page to the dist folder, or something like that... At the end, I will have a kind of HTML page compatible, except maybe for the
A work colleague told me that Webpack with its graph was able to remove the dead code from included file. But I guess it's not quite that. It can only remove unused files? Best regards, |
* v3: 3.7.0 Add .ejs to Html#supportedExtensions (see #773)
I've released assetgraph 3.7.0 and assetgraph-builder 5.5.0 where the .ejs extension is interpreted as HTML, so at least that should be out of the way now so the
AssetGraph is using an HTML parser to build a DOM of all HTML files (now including .ejs) in the project, so which poses a problem for template constructs that aren't valid HTML. However, we have some mechanisms in place that will rewrite the most typical syntaxes, including However, there's still some work to do in order to get AssetGraph to understand all the essential parts of your project well enough to be able to do a production build of it -- I assume that's what you're aiming for, right? Come to think of it, you probably want to use assetgraph-builder for that. Still, since assetgraph-builder uses assetgraph internally, some of the support work would have to happen in AssetGraph itself. It's not a perfect fit right now, but I'd at least like to spend a little time exploring the use case :) In any case, assetgraph(-builder) will need a bit of help discovering those templates. You'll need to bring them all into scope by mentioning them all at the |
If your page is actually just a static site I would highly recommend a separate assembly step that takes your code from your .ejs authoring abstraction and outputs a working website. This is the ideal input for assetgraph. If this is not an option I guess you'll either need to try your luck with @papandreou 's suggestion or help us out with our thoughts on extensions for v4, do you could implement .ejs templating support |
Hi,
I was looking for a bundling too like Webpack, but WebPack is not appropriate when the entry are not javascript file. So I found AssetGraph which claims not to have this limitation. Do I'm right ?
I did some test and it's a very interesting tool, good work guys :)
But something is missing, how could I load
*.ejs
assets ? Do I need to create a new relations javascript file describing *.ejs file ?My web site structure is something like :
is including
header.ejs
andfooter.ejs
is including some javascript src tag
is including some css link tag
is including some javascript src tag
Does this tool is appropriate to bundling my web site. Ideally I would like to :
Best regards,
The text was updated successfully, but these errors were encountered: