Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/vb6/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在服务器端获得已编译的meteor css包_Meteor - Fatal编程技术网

如何在服务器端获得已编译的meteor css包

如何在服务器端获得已编译的meteor css包,meteor,Meteor,我在client/目录中有多个scss样式表。我有一个特定的页面,它被呈现在服务器端,并且在没有Meteor应用程序的情况下静态地提供服务(它是电子邮件取消订阅确认) 我想在此页面上加载我的主站点css包 对于这个目标,我需要的只是这个包的文本内容,或者更好的是一个绝对路径。问题是,Assets.getText()只能访问private/directory 然而,Meteor知道服务器端的这个包文件路径,因为它以某种方式使用index.html提供它 有什么方法可以自己做吗?如果我正确理解了这个

我在client/目录中有多个scss样式表。我有一个特定的页面,它被呈现在服务器端,并且在没有Meteor应用程序的情况下静态地提供服务(它是电子邮件取消订阅确认)

我想在此页面上加载我的主站点css包

对于这个目标,我需要的只是这个包的文本内容,或者更好的是一个绝对路径。问题是,Assets.getText()只能访问private/directory

然而,Meteor知道服务器端的这个包文件路径,因为它以某种方式使用index.html提供它


有什么方法可以自己做吗?

如果我正确理解了这个问题,通过仔细观察,我可以得到如下答案:

path.join(
  path.dirname(
    path.join(
      __meteor_bootstrap__.serverDir,
      __meteor_bootstrap__.configJson.clientPaths['web.browser']
    )
  ),
  "merged-stylesheets.css"
)
<link rel="stylesheet" type="text/css" href="/merged-stylesheets.css">
在服务器端。将移动版本的
web.browser
更改为
web.cordova

但如果您想将其包含在静态页面中,也可以这样做:

path.join(
  path.dirname(
    path.join(
      __meteor_bootstrap__.serverDir,
      __meteor_bootstrap__.configJson.clientPaths['web.browser']
    )
  ),
  "merged-stylesheets.css"
)
<link rel="stylesheet" type="text/css" href="/merged-stylesheets.css">


取决于您如何为静态页面提供服务

如果我正确理解了问题,通过查看,我可以得到如下信息:

path.join(
  path.dirname(
    path.join(
      __meteor_bootstrap__.serverDir,
      __meteor_bootstrap__.configJson.clientPaths['web.browser']
    )
  ),
  "merged-stylesheets.css"
)
<link rel="stylesheet" type="text/css" href="/merged-stylesheets.css">
在服务器端。将移动版本的
web.browser
更改为
web.cordova

但如果您想将其包含在静态页面中,也可以这样做:

path.join(
  path.dirname(
    path.join(
      __meteor_bootstrap__.serverDir,
      __meteor_bootstrap__.configJson.clientPaths['web.browser']
    )
  ),
  "merged-stylesheets.css"
)
<link rel="stylesheet" type="text/css" href="/merged-stylesheets.css">


根据您为静态页面提供服务的方式,接受的答案仅在开发中有效。在生产环境中,css文件名是散列文件,例如,
facc2661135083eeff000051c65e72e2ad910050.css
而不是
merged stylesheets.css

这对我在开发和生产方面很有用:

让cssPath=\uuuuu meteor\u bootstrap\uuuu.serverDir.replace('/server','/web.browser');
cssPath+=“/”+fs.readdirSync(cssPath.find)(文件=>file.slice(-4)=“.css”);

仅供参考,我正在使用此服务器端使用上述css进行预渲染:

接受的答案仅在开发中有效。在生产环境中,css文件名是散列文件,例如,
facc2661135083eeff000051c65e72e2ad910050.css
而不是
merged stylesheets.css

这对我在开发和生产方面很有用:

让cssPath=\uuuuu meteor\u bootstrap\uuuu.serverDir.replace('/server','/web.browser');
cssPath+=“/”+fs.readdirSync(cssPath.find)(文件=>file.slice(-4)=“.css”);
仅供参考,我正在使用此服务器端使用上面的折叠css进行预渲染:

来自:
的css和特殊目录外的HTML文件仅加载到客户端,不能从服务器代码中使用。
因此,不,我认为这是不可能的。从:
中,特殊目录外的css和HTML文件仅加载到客户端,不能从服务器代码中使用。
因此,不,我认为这是不可能的。