【发布时间】:2020-01-11 04:56:14
【问题描述】:
我的 package.json 文件如下所示:
{
"name": "xxxx",
"version": "1.0.0",
"private": true,
"devDependencies": {
"grunt": "^1.0.4",
"grunt-autoprefixer": "^3.0.4",
"grunt-contrib-cssmin": "^3.0.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-uglify": "~0.5.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-package-modules": "^1.0.0",
"grunt-sass": "^3.1.0",
"node-sass": "^4.12.0"
},
"dependencies": {
"bootstrap": "^4.2.1",
"jquery": "^3.3.1",
"popper.js": "^1.14.6"
}
}
我有一个 Gruntfile.js,它执行某些任务,例如文件监视、SASS 编译、自动前缀、缩小,...
示例任务:
sass: { // sass tasks
dist: {
options: {
compass: true, // enable the combass lib, more on this later
style: 'expanded', // we don't want to compress it
implementation: sass,
sourceMap: true
},
files: {
'web/var/static/css/main.css': 'web/var/static/sass/main.scss' // this is our main scss file
}
}
},
我的 node_modules 文件夹位于项目根目录中。整个项目不公开,只公开/web/var/static/内的所有内容。
所需的库(如 bootstrap、jquery 和 popper.js)应该可以公开访问,因为它们部分直接包含在项目视图中,如 /var/static/lib/jquery/dist/jquery.min.js。否则,我会使用自定义的 grunt 任务将它们粘合在一起。
目前 grunt 将依赖项放入项目根目录下的 node_modules 文件夹中。我怎么说 grunt 把那些特定的依赖放到公共的/var/static/lib/ 文件夹中?
【问题讨论】:
标签: javascript dependencies gruntjs node-modules package.json