node.js - 如何将express和gulp结合使用
迷茫
迷茫 2017-04-17 14:53:38
0
1
621

最近在做一个公司官网,纯静态页面,服务端用express,模板引擎用jade。

我现在想知道,我如果前端需要使用一些库比如bootstrap之类的话,应该用bower去管理还是npm去管理呢?

然后如果结合gulp一起使用,我想使用一些live-reload,wiredep之类的插件,不知道怎么结合起来。

如果有相关的例子就好了

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
Ty80

Whether to use bower or npm mainly depends on your packaging strategy. My personal suggestion is that npm is better.

Gulp is actually not directly related to your express. You have not seen the essence here clearly. Is there a big difference between your use of express and your use of PHP? How you use gulp in php can be used in express. It's just that express is easier to combine and more flexible.

Note that express’s static directory can be configured by yourself, so a simple combination

if (app.get('env') === 'development') {
    app.use(express.static(path.join(__dirname, '/public/dev')));
} else {
    app.use(express.static(path.join(__dirname, '/public/dist')));
}

Just put the code packaged by gulp in dist,

Of course, if you want to integrate the entire development environment, you need to use a gulp-express plug-in. I have never done that. The plug-in should be this: https://www.npmjs.com/package...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template