Javascript 源映射到公共目录外的文件
我的文件结构如下:Javascript 源映射到公共目录外的文件,javascript,angularjs,npm,gruntjs,source-maps,Javascript,Angularjs,Npm,Gruntjs,Source Maps,我的文件结构如下: /server/ - package.json - node_modules/ - Gruntfile.js /public/ - index.html - assets/ require('load-grunt-tasks')(grunt); grunt.initConfig({ //concat js concat: { options: { separator: ';', sourceMap
/server/
- package.json
- node_modules/
- Gruntfile.js
/public/
- index.html
- assets/
require('load-grunt-tasks')(grunt);
grunt.initConfig({
//concat js
concat: {
options: {
separator: ';',
sourceMap: true
},
lib: {
src: [
'./node_modules/angular/angular.js',
'./node_modules/angular-route/angular-route.js',
'./node_modules/angular-animate/angular-animate.js'
],
dest: '../public/assets/build/lib/lib.min.js'
}
},
//minify js
uglify: {
options: {
mange: true,
compress: true,
sourceMap: true
},
lib: {
src: '<%= concat.lib.dest %>',
dest: '<%= concat.lib.dest %>'
}
}
});
grunt.registerTask('build', ['concat', 'uglify']);
在/server
中时,我运行npm install
,它将Angular
之类的东西下载到/server/node\u模块中
然后运行grunfile.js
,如下所示:
/server/
- package.json
- node_modules/
- Gruntfile.js
/public/
- index.html
- assets/
require('load-grunt-tasks')(grunt);
grunt.initConfig({
//concat js
concat: {
options: {
separator: ';',
sourceMap: true
},
lib: {
src: [
'./node_modules/angular/angular.js',
'./node_modules/angular-route/angular-route.js',
'./node_modules/angular-animate/angular-animate.js'
],
dest: '../public/assets/build/lib/lib.min.js'
}
},
//minify js
uglify: {
options: {
mange: true,
compress: true,
sourceMap: true
},
lib: {
src: '<%= concat.lib.dest %>',
dest: '<%= concat.lib.dest %>'
}
}
});
grunt.registerTask('build', ['concat', 'uglify']);
require('load-grunt-tasks')(grunt);
grunt.initConfig({
//康卡特js
康卡特:{
选项:{
分隔符:';',
sourceMap:true
},
库:{
src:[
“./node_modules/angular/angular.js”,
“./node_modules/angular route/angular route.js”,
“./node_模块/angular animate/angular animate.js”
],
dest:“../public/assets/build/lib/lib.min.js”
}
},
//缩小js
丑陋的:{
选项:{
曼奇:没错,
是的,
sourceMap:true
},
库:{
src:“”,
目标:“”
}
}
});
grunt.registerTask('build',['concat','uglify');
grunt文件的工作原理与预期的一样,可以使用源映射来压缩和缩小角度模块。问题是域名指向公共目录,但是源代码映射想要指向服务器目录中的源代码,我认为这不起作用
我该如何避开这个问题?我是否必须将节点_模块放在公共目录的根目录中?如果可能的话,我不希望在公共目录中有任何预编译代码,原因是当我启动站点时,我可以简单地通过FTP将公共目录传输到服务器,从而减少不必要的容量