frozeman / meteor-build-client

A tool to bundle the client part of a Meteor app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JS and CSS files not included in index.html file

brettg2 opened this issue · comments

After running meteor-build-client (version 1.01), the index.html file is created but it does not include the js and css files the bundler generated.

Hello @brettg2 ,

You are first to report it, since its release it's been very stable.
To further investigate this issue we need:

  1. Screenshot or tree . of /bundle/programs/ (with nested files and dirs) after building meteor-project locally, to see what files do you have?
  2. What meteor --version are you on?

@brettg2 let me know if you had any progress with this issue

I have the same issue, actually:

Meteor 1.11.1

It was working before on older meteor versions.

@hamzamu post your template or at least some other code, to help you with:

  1. Screenshot or tree . inside /bundle/programs/ (with nested files and dirs) after building meteor-project locally, to see what files do you have?
  2. Template/Layout or at least some other code

@hamzamu is this issue solved?

Closed due to silence at issue owner end.
Feel free to reopen it in case if the issue still persists on your end.

@dr-dimitru

Apologies for not seeing these updates.

Attached is the "tree ." output (tree.txt) of my bundle/programs directory as well as the index.html (index.txt) generated from the meteor-build-client tool. I ran the tool on the most updated version of meteor (1.11.1) and it still came back without any attachments to the css and js files.

Let me know if you need anything else. Thank you

tree.txt

index.txt

Reopening, will investigate closer.
Stay tuned! Thank you for update @brettg2

@hamzamu do you experience it as well?

@hamzamu @brettg2

You never mentioned what arguments you're passing to meteor-build-client, please post full command and arguments when executing meteor-build-client

@brettg2 @hamzamu I did testing against couple projects where we use this library. Everything looks great.
The only reason why you might end up with not having CSS and JS as single file is running with --debug flag. Make sure you don't use --debug flag, it meant to be used only when developing stuff for meteor or this package.

To get insight into building process use --verbose flag, and I actually encourage you to run build command with --verbose flag and post its output here.

Thank you, looking forward your reply

@dr-dimitru

here is the full command I used:

meteor-build-client ..\Application\pl_DotNetDev\Charon.ProLease.Application\app -p ""

@dr-dimitru

I added the --verbose flag to the build command. Here is the output:

build.output.txt

@brettg2 are you sure you're on the latest meteor-build-client release?

meteor-build-client --version

@dr-dimitru

I have version 1.0.1. Is that the latest?

@brettg2 yes, it is. I'm asking as your output is missing final logs with an Object of generated files, and this was added in the latest release. Any chance you having older version? Like running under other user/root?

What's meteor release you're on?
What's your environment? Win/Mac/Linux?

I tested it on various older and new apps, all of it is good on my end.

I've just updated documentation, read it thoroughly, hopefully it would help.

@dr-dimitru

After further investigation, it looks like it is not including the meteor headers at all. What might be useful is looking at my root html file (blaze template source file) that includes a body and head tag. Would the tool see the head tag and have an issue appending the meteor code before it? Please see the attached body.txt for more context. Thank you

body.txt

@dr-dimitru

We were able to create a fixed version of this tool a while ago (https://github.com/brettg2/meteor-build-client) that works correctly. Let me know if there is a way to spot a difference that could cause the issue. The correct index.html (index.working.txt) output it generates is attached. Thank you

index.working.txt

edit: I am working in Windows with meteor version 1.11.1

@brettg2 Thank you for details.
Will compare your fork this weekend.

@brettg2 changes from your proposed PR were used in v1.0.0, your changes are in place starting from :196

Only difference is here:

@@ meteor.js
- var cssFile = fs.readFileSync(path.join(buildPath, css), {encoding: 'utf8'});
+ var cssFile = fs.readFileSync(path.join(outputPath, css), { encoding: 'utf8' });

When I change it to your option using buildPath instead of outputPath it throws file not found exception.
This scenario triggered with -p "" flag, I tested it thoroughly no issues found on my end. Any idea why?

@dr-dimitru

Are you merging that with the latest 1.0.1 or 1.0.0 version? I built my version off of v1.0 but haven't checked it since then. I will work on this later today. Thank you

@brettg2 there's no codebase changes between v1.0.1 and v1.0.0
Keep me updated after running checks on your end, thank you

Hello @dr-dimitru, sorry for being late, I will check it today.

I never used this before, but on Meteor 1.11 it's not working for me.
The generated head.html and body.html don't contain the template strings it searches for in the regex.

@dr-dimitru

To recreate in windows:

meteor create simple-todos
cd simple-todos
meteor-build-client .\app

The generated index.html contains no references to the js or css files.

@dr-dimitru any updates?

@brettg2 thank you for bumping in this one.
Extremely busy times for me. But I got this on radar, no.1 on my open source list, hope to put my hands on this weekend.
Thank you for understanding.

@brettg2, @dr-dimitru,

I think this is a documentation problem. The Template section of the readme is intended to explain this, but I think it does a bad job.

  • In the examples section there is no mention that you need to explicitly add tags to your <head> section or your <body> section, yet this is required.
  • When I read the Template section, I thought it was referring to setting up your own template via the --template flag. At the very least I was confused by it. (Plus none of this works for blaze projects without #65).
  • I found the only way to understand what this does and does not do was to step through the code. (At this point there are a lot of bugs & caveats in this package. But it does an awesome thing!)

@brettg2 I think you need to add:

  • <meteor-bundled-css /> to your <head> section
  • <meteor-bundled-js />) to your <body> section

And it should work for you because I think the default meteor create is a react app which outputs head.html & body.html to it's build directory.

@brettg2, This line might be an issue too:
https://github.com/frozeman/meteor-build-client/blob/master/meteor.js#L172

Apparently, you need to use the --debug flag for it to work?

This is a funny package. 😺

EDIT: OK, I have been using the --usebuild flag. For this to work you need to use the --debug flag if you did a meteor build --debug which is what I did.

SUMMARY: if you build without --debug then this code: https://github.com/frozeman/meteor-build-client/blob/master/meteor.js#L161-L167 will pull in the minified files which are bundled into 2 files.

Please update to the latest release, this issue should be solved now

Feel free to close it in case if the issue is solved on your end.

Closed due to silence at issue owner end.
Feel free to reopen it in case if the issue still persists on your end.