我正在开发一个现有项目,将bower
替换为yarn
,并将angularjs
从1.2.9
升级为1.3.0
我已经让它在我的本地系统上工作但是在jenkins
运行deploy
grunt任务时遇到文件路径问题时它失败了,奇怪的是它在jenkins上它抱怨我的本地路径
Errno::ENOENT on line ["33"] of /var/lib/jenkins/.rvm/gems/ruby-2.3.3/gems/compass-1.0.3/lib/compass/exec/global_options_parser.rb: No such file or directory @ realpath_rec - /home/leonidas
/home/leonidas
是我的本地路径
这是我的Gruntfile.js
,
'use strict';
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
var serveStatic = require('serve-static');
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: '../public'
};
try {
yeomanConfig.app = require('./package.json').appPath || yeomanConfig.app;
} catch (e) {}
grunt.initConfig({
ngtemplates: {
myApp: {
options: {
base: 'app',
concat: '<%= yeoman.dist %>/scripts/scripts.js'
},
src: ['app/views/**/*.html'],
dest: '.tmp/template.js'
}
},
yeoman: yeomanConfig,
watch: {
all : {
options : { livereload: true },
files: [
'<%= yeoman.app %>/{,*/}*.html',
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
tasks: ['jshint']
}
},
connect: {
proxies: [{
context: '/api',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}, {
context: '/public/api',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}, {
context: '/print',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}, {
context: '/users',
host: '127.0.0.1',
port: 5000,
https: false,
changeOrigin: false
}],
livereload: {
options: {
port: 9000,
hostname: '0.0.0.0',
middleware: function () {
return [
require('connect-livereload')(),
proxySnippet,
serveStatic('.tmp'),
serveStatic('test'),
serveStatic(yeomanConfig.app)
];
}
}
},
test: {
options: {
port: 9001,
middleware: function () {
return [
serveStatic('.tmp'),
serveStatic('test')
];
}
}
},
teste2e: {
options: {
port: 9002,
hostname: 'localhost',
middleware: function () {
return [
proxySnippet,
serveStatic('.tmp'),
serveStatic('test'),
serveStatic(yeomanConfig.app)
];
}
}
}
},
open: {
server: {
url: 'http://localhost:<%= connect.livereload.options.port %>'
}
},
clean: {
options: {
force: true
},
dist: ['.tmp', '<%= yeoman.dist %>/*'],
server: '.tmp'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js'
]
},
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: true
},
dev: {
configFile: 'karma.conf.js',
singleRun: false
},
e2e: {
configFile: 'karma-e2e.conf.js',
singleRun: true
}
},
coffee: {
dist: {
files: {
'.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
}
},
test: {
files: [{
expand: true,
cwd: '.tmp/spec',
src: '*.coffee',
dest: 'test/spec'
}]
}
},
compass: {
dist: {
options: {
sassDir: '<%= yeoman.app %>/styles',
cssDir: '.tmp/styles',
imagesDir: '<%= yeoman.app %>/images',
javascriptsDir: '<%= yeoman.app %>/scripts',
fontsDir: '<%= yeoman.app %>/styles/fonts',
importPath: '<%= yeoman.app %>/components',
relativeAssets: true
}
},
server: {
options: {
debugInfo: true
}
}
},
concat: {
dist: {
files: {
'<%= yeoman.dist %>/scripts/scripts.js': [
'.tmp/scripts/{,*/}*.js',
'<%= yeoman.app %>/scripts/{,*/}*.js'
]
}
}
},
useminPrepare: {
html: '<%= yeoman.app %>/index.html',
options: {
dest: '<%= yeoman.dist %>'
}
},
rev: {
files: {
src: ['<%= yeoman.dist %>/lib/components.js', '<%= yeoman.dist %>/lib/components-ie8.js', '<%= yeoman.dist %>/lib/components-ie.js', '<%= yeoman.dist %>/scripts/scripts.js', '<%= yeoman.dist %>/styles/main.css']
}
},
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
dirs: ['<%= yeoman.dist %>']
}
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
cssmin: {
dist: {
files: {
'<%= yeoman.dist %>/styles/main.css': [
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/styles/{,*/}*.css'
]
}
}
},
htmlmin: {
dist: {
options: { },
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
src: ['*.html', 'views/*.html'],
dest: '<%= yeoman.dist %>'
}]
}
},
ngmin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.dist %>/scripts',
src: '*.js',
dest: '<%= yeoman.dist %>/scripts'
}]
}
},
uglify: {
dist: {
files: {
'<%= yeoman.dist %>/scripts/scripts.js': ['<%= yeoman.dist %>/scripts/*.js']
}
}
},
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'.htaccess',
'fonts/**/*',
'scriptx/**/*',
'lib/**/*',
'images/{,*/}*.{gif,webp,svg}'
]
}]
}
}
});
grunt.registerTask('server', [
'clean:server',
'coffee:dist',
'compass:server',
'configureProxies',
'connect:livereload',
'open',
'watch'
]);
grunt.registerTask('test', [
'clean:server',
'coffee',
'compass',
'connect:test',
'karma:unit'
]);
grunt.registerTask('test-e2e', [
'clean:server',
'coffee',
'compass',
'configureProxies',
'connect:teste2e',
'karma:e2e'
]);
grunt.registerTask('deploy', [
'clean:dist',
'coffee',
'compass:dist',
'useminPrepare',
'imagemin',
'cssmin',
'htmlmin',
'ngtemplates',
'concat',
'ngmin',
'uglify',
'copy',
'rev',
'usemin'
]);
grunt.registerTask('build', [
'clean:dist',
'jshint',
'karma:unit',
'compass:dist',
'useminPrepare',
'imagemin',
'cssmin',
'htmlmin',
'ngtemplates',
'concat',
'ngmin',
'uglify',
'copy',
'rev',
'usemin'
]);
grunt.registerTask('default', ['build']);
};
只是为了澄清我不是一个前端开发者,我正在学习,因为我正在做事。
答案 0 :(得分:0)
这个问题已经过去了很多时间,我为遇到这个问题的人回答。
我的情况是由于bower_components
文件夹的位置错误。以问题中粘贴的Gruntfile.js为例,指南针的importPath
为:
importPath: '<%= yeoman.app %>/bower_components',
这是/app/bower_components
目录。确保bower install
命令的输出在/app
文件夹中。在大多数情况下,只需添加或检查包含以下内容的.bowerrc
:
{
"directory": "app/bower_components"
}