Referencing resources in node_modules folder

孤人 提交于 2019-12-03 21:42:20

I was able to copy with the node_modules bootstrap resources with a simple Grunt task:

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"
    }
}

Using grunt plug-in: grunt-contrib-copy

As explained in This Blog Post, you can create a "Static Route" instead of exposing the node_modules structure totally.

app.use('/scripts', express.static(__dirname + '/node_modules/bootstrap/dist/'));

But that may not be the best method. It seems that packages that come with resources also come with Grunt files as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!