how to determine which css file will be sent to clients

佐手、 提交于 2019-12-11 03:04:26

问题


I started a simple project with Meteor. But now it is getting complicated. I am trying add a management panel for project. I want to separate site and its panel. But every css and js files are both sent to site and management.

Environment: I am hosting project at meteor.com. My development machine is Windows 7. I cant use meteorite. If you are going to suggest me to use mrt add router, you are welcome. but currently i cant do it.

Current directory structure:

  • client (client.js, index.html, css files, other js files like jquery plugins)
  • server (server.js)
  • public (image files for UI)

Update

I have 1 index file which is:

<head>
    <title>Index</title>
</head>

<body>
    {{> root}}
</body>

root template is using some other templates inside. I may use 2 different index files. 1 for site and 1 for management panel.

root template:

<template name="root">
    {{#if adminURL}}
        {{> adminLogin}}
    {{else}}
        {{> site}}
    {{/if}}
</template>

adminLogin template:

<template name="adminLogin">
    {{#if currentUser}}
        {{> management}}
    {{else}}
        admin login page.
            <div style="float: right">
              {{loginButtons align="right"}}
            </div>
    {{/if}}
</template>

management template:

<template name="management">
    <div id="header" class="navbar">
       ....
    </div>
    <div id="container" class="row-fluid">
       ....
    </div>
</template>

site template:

<template name="management">
     <h1>Hello World!</h1>
</template>

回答1:


TLDR; If you put your files over in the /public folder, they wont automatically be sent to the client, they just need to be referenced manually.

To reference your files manually, just add them into your HTML just before where your </body> is. So for a file at /public/js/myFile1.js :

    <script type="text/javascript"  src="/js/myFile1.js"></script>
</body>

All of the following are sent to the client, all js,css,font & html files in the top level (root directory that & subdirectories that aren't:

  • server
  • public
  • assets
  • packages
  • public
  • folders that begin with a '.'
  • or tests (not sure)

are all concatenated into a single file and sent to the client.

So in the public folder meteor pretty much ignores them. You can manually reference them to include them if you wish.

Another option might be to make a private package so you can explicitly decide on which files you want to include, this makes it easy to also use your same design on different related meteor apps.



来源:https://stackoverflow.com/questions/18586986/how-to-determine-which-css-file-will-be-sent-to-clients

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!