Changes in build system? (CSS and HTML imports)


#1

After not having used Meteor for some time (2 years or so) I now come back to Meteor for a new project. It seems to me that the build system changed a bit.

  1. It seems the CSS files are not anymore loaded in the order of their filenames. I tried to import the Roboto font @import url('https://fonts.googleapis.com/css?family=Roboto:100,400'); in a _main.css file, but I get the error There are some @import rules those are not taking effect as they are required to be in the beginning of the file.. How can I make sure that it is loaded first of all (it is even the only CSS file I have in my project)?

  2. I must now explicitly import the main.html in main.js. When did this change? I couldn’t find this in the documentation.


#2

Regarding issue 1 it seems that there is a little bug in the current build system. When there is only an @import in des CSS file then meteor does not load it (and warns in the shell console durting startup). When there are some additional CSS definitions (after the import) everything works fine.


#3

Glad you sorted out No 1.

With 2, you don’t need to explicitly import these.
It’s recommended that you do, and you can turn off eager file loading, but they remain on by default for backwards compatibility. (except for the imports folder, which is new from Meteor 1.3 - early 2016)
Feel free to ignore the recommendation in the guide if you prefer


#4

@coagmano Are you sure that the HTML files are still loaded by default? Because when I create a new meteor project (Meteor V 1.7.0.3) and comment out the import './main.html' in main.js then the site breaks (Uncaught TypeError: Cannot read property 'onCreated' of undefined). So it seems that this is not the default case anymore.


#5

Ah right, I didn’t realise the create templates had changed to disable eager loading by default…
You can restore the original behaviour by deleting the "meteor": { "mainModule": { part from your package.json

That changed in 1.7, so it’s very recent. I hadn’t noticed because existing projects updated to 1.7 keep the old behaviour

And while html files are still eagerly loaded, Blaze compiles .html into .html.js which then behaves like javascript files, skipping the eager loading behaviour