通过NPM安装使用Zurb的基础

时间:2022-10-22 09:20:12

I'm fairly new to using nodejs and npm, so please excuse any naivety. I want to use Foundation in my latest project and use npm to get it installed. This has worked and my node_modules now contains the foundation dir.

我是使用nodejs和npm的新手,所以请原谅任何天真。我想在我的最新项目中使用Foundation并使用npm来安装它。这有效,我的node_modules现在包含基础目录。

How do I now use Foundation in my markup? I have a /public dir which contains my views, but surely it would be bad practise to point references to the node_modules dir? Do I create a custom route in app.js to files within the foundation dir? I'm not sure what the best practise is?

我现在如何在我的标记中使用Foundation?我有一个/ public目录,其中包含我的观点,但肯定是指向node_modules目录的引用是不好的做法?我是否在app.js中为基础目录中的文件创建自定义路由?我不确定最佳做法是什么?

Help appreciated.

4 个解决方案

#1


0  

I think you misunderstood something about NodeJS. NodeJS in a website is the backend like PHP, ASP or Ruby.

我觉得你误解了NodeJS。网站中的NodeJS是PHP,ASP或Ruby等后端。

Foundation Framework is a CSS framework, so it's for the client, the frontend.

Foundation Framework是一个CSS框架,因此它适用于客户端,即前端。

To use it in a website running by NodeJS, just put the library that you downloaded in Zurb website in the public directory and use it in your views like this :

要在NodeJS运行的网站中使用它,只需将您在Zurb网站下载的库放在公共目录中,并在您的视图中使用它,如下所示:

<link rel="stylesheet" href="styles/foundation.css">

#2


8  

You need register foundation as a stylus plugin. If you are using connect or express try something like this:

你需要注册基础作为手写笔插件。如果您使用connect或express尝试这样的事情:

var express = require('express'),
    stylus = require('stylus'),
    app = express();

app.use(stylus.middleware({
    compile: function (str, path) {
        return stylus(str)
            .set('filename', path)
            .use(require('foundation')());
    }
}));

Then in your styl file you can

然后在您的styl文件中即可

@import "foundation"

#3


3  

Installing Foundation with npm

npm install foundation-sites

Then, copy Foundation's files to your web server and reference it with a <link> tag.

然后,将Foundation的文件复制到Web服务器并使用 标记引用它。

Installing Foundation with Bower

bower install foundation

Then, copy Foundation's files (or the entire bower_components directory) to your web server and reference it with a <link> tag.

然后,将Foundation的文件(或整个bower_components目录)复制到Web服务器,并使用 标记引用它。


Foundation's GitHub page and their Getting Started page has more information on the different ways to set up Foundation.

Foundation的GitHub页面及其Getting Started页面提供了有关设置Foundation的不同方法的更多信息。

#4


0  

You may be able to pull in the foundation code. git://github.com/ch1c0t/bower-foundation-css.git OR git://github.com/mmcgahan/sass-foundation.git. Bower is a client side package manager similar to npm, but for the client. http://bower.io/

您也许可以提取基础代码。 git://github.com/ch1c0t/bower-foundation-css.git或git://github.com/mmcgahan/sass-foundation.git。 Bower是一个客户端包管理器,类似于npm,但是对于客户端。 http://bower.io/

#1


0  

I think you misunderstood something about NodeJS. NodeJS in a website is the backend like PHP, ASP or Ruby.

我觉得你误解了NodeJS。网站中的NodeJS是PHP,ASP或Ruby等后端。

Foundation Framework is a CSS framework, so it's for the client, the frontend.

Foundation Framework是一个CSS框架,因此它适用于客户端,即前端。

To use it in a website running by NodeJS, just put the library that you downloaded in Zurb website in the public directory and use it in your views like this :

要在NodeJS运行的网站中使用它,只需将您在Zurb网站下载的库放在公共目录中,并在您的视图中使用它,如下所示:

<link rel="stylesheet" href="styles/foundation.css">

#2


8  

You need register foundation as a stylus plugin. If you are using connect or express try something like this:

你需要注册基础作为手写笔插件。如果您使用connect或express尝试这样的事情:

var express = require('express'),
    stylus = require('stylus'),
    app = express();

app.use(stylus.middleware({
    compile: function (str, path) {
        return stylus(str)
            .set('filename', path)
            .use(require('foundation')());
    }
}));

Then in your styl file you can

然后在您的styl文件中即可

@import "foundation"

#3


3  

Installing Foundation with npm

npm install foundation-sites

Then, copy Foundation's files to your web server and reference it with a <link> tag.

然后,将Foundation的文件复制到Web服务器并使用 标记引用它。

Installing Foundation with Bower

bower install foundation

Then, copy Foundation's files (or the entire bower_components directory) to your web server and reference it with a <link> tag.

然后,将Foundation的文件(或整个bower_components目录)复制到Web服务器,并使用 标记引用它。


Foundation's GitHub page and their Getting Started page has more information on the different ways to set up Foundation.

Foundation的GitHub页面及其Getting Started页面提供了有关设置Foundation的不同方法的更多信息。

#4


0  

You may be able to pull in the foundation code. git://github.com/ch1c0t/bower-foundation-css.git OR git://github.com/mmcgahan/sass-foundation.git. Bower is a client side package manager similar to npm, but for the client. http://bower.io/

您也许可以提取基础代码。 git://github.com/ch1c0t/bower-foundation-css.git或git://github.com/mmcgahan/sass-foundation.git。 Bower是一个客户端包管理器,类似于npm,但是对于客户端。 http://bower.io/