如何确定要发送给客户端的css文件

时间:2022-07-06 16:39:59

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.

我用流星开始了一个简单的项目。但现在情况越来越复杂。我正在尝试为项目添加一个管理面板。我想把网站和它的面板分开。但是每个css和js文件都被发送到站点和管理。

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.

环境:我在气象局主持项目。我的开发机器是Windows 7。我不能用陨石。如果你打算建议我使用mrt添加路由器,欢迎你。但目前我做不到。

Current directory structure:

当前目录结构:

  • client (client.js, index.html, css files, other js files like jquery plugins)
  • 客户端(客户端。js、索引。html、css文件、jquery等js文件)
  • server (server.js)
  • 服务器(server.js)
  • public (image files for UI)
  • 公共(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.

根模板中使用了其他一些模板。我可以使用两个不同的索引文件。1为现场,1为管理面板。

root template:

根模板:

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

adminLogin template:

adminLogin模板:

<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 个解决方案

#1


3  

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.

TLDR;如果您将您的文件放在/公用文件夹中,它们不会自动被发送到客户端,它们只是需要手动引用。

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 :

要手动引用文件,只需在之前将它们添加到HTML中。因此,对于/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:

下面的所有内容都被发送到客户端,所有的js、css、字体和html文件都在顶层(根目录和子目录没有:

  • 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.

另一种选择可能是创建一个私有包,这样您就可以明确地决定要包含哪些文件,这使得在不同相关的流星应用程序上也可以很容易地使用相同的设计。

#1


3  

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.

TLDR;如果您将您的文件放在/公用文件夹中,它们不会自动被发送到客户端,它们只是需要手动引用。

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 :

要手动引用文件,只需在之前将它们添加到HTML中。因此,对于/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:

下面的所有内容都被发送到客户端,所有的js、css、字体和html文件都在顶层(根目录和子目录没有:

  • 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.

另一种选择可能是创建一个私有包,这样您就可以明确地决定要包含哪些文件,这使得在不同相关的流星应用程序上也可以很容易地使用相同的设计。