![](/img/trans.png)
[英]Angular 9 Typescript referencing node_modules to fix MIME error
[英]Referencing resources in node_modules folder
我目前正在编写我的第一个Node.js应用程序。 我最近通过npm安装了bootstrap(遵循bootstrap网站上的说明 ),并且想知道引用bootstap.min.css(以及其他感兴趣的文件)的“标准”方式。 最好使用grunt / gulp将我需要的资源复制(捆绑和缩小)到项目结构中?
任何帮助,将不胜感激。
我能够通过一个简单的Grunt任务使用node_modules引导程序资源进行复制:
copy: {
bootstrapSrcCss: {
src: "./node_modules/bootstrap/dist/css/bootstrap.css",
dest: "./public/src/css/bootstrap.css"
},
bootstrapSrcJs: {
src: "./node_modules/bootstrap/dist/js/bootstrap.js",
dest: "./public/src/js/bootstrap.js"
}
}
使用grunt插件:grunt-contrib-copy
如本博客文章中所述 ,您可以创建“静态路由”,而不用完全暴露node_modules结构。
app.use('/scripts', express.static(__dirname + '/node_modules/bootstrap/dist/'));
但这可能不是最好的方法。 似乎资源附带的软件包也随Grunt文件一起提供。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.