Ciao,
dopo diverse prove non capisco come mai non funziona la base fornita da yoeman. ecco cosa faccio, mi credo un host in locale (yoeman.localhost) in cui faccio eseguire il comando per generare lo scheletro di angular
aggiungo anche l'utilizzo di bootstrap e dico ok a tutti i plugin che vuole per default. Il comando esegue tutto benissimo e crea lo scheletro, poi mi accingo a guardare il sito e non funzionano i puntamenti ai link dei css e js perchè sono messi
codice HTML:
<script src="bower_components/jquery/dist/jquery.js"></script>
devo quindi correggere il path in
codice HTML:
<!-- inserisco / per path assoluto -->
<script src="/bower_components/jquery/dist/jquery.js"></script>
Essendo che trovo la base di lavoro in /app, mi accingo ad avviare grunt (dalla cli partendo dalla root) e chiaramente una moltitudine di errori a non finire!!
provo quindi a inserire un Gruntfile mio semplificato con le prime necessità:
codice:
module.exports = function(grunt) {
// Configurazione del progetto.
grunt.initConfig({
// watch: {
// files: 'js/*.js'
//,
//tasks: 'concat:dist min'
// }
// pkg: grunt.file.readJSON('package.json'),
// configure jshint to validate js files -----------------------------------
jshint: {
options: {
reporter: require('jshint-stylish') // use jshint-stylish to make our errors look and read good
},
// when this task is run, lint the Gruntfile and all js files in src
build: "app/scripts/**/*.js"// 'js/**/*.js
},
watch: {
// for stylesheets, watch css and less files
// only run less and cssmin stylesheets:
files:["app/styles/**/*.css","app/view/**/*.html","app/*.html","app/*.php"],
scripts: {
files: ['app/scripts/**/*.js'],
tasks: ['jshint']
},
options:{
livereload:{
port:9000
}
}
}
});
// ===========================================================================
// LOAD GRUNT PLUGINS ========================================================
// ===========================================================================
// we can only load these if they are in our package.json
// make sure you have run npm install so our app can find these
grunt.loadNpmTasks('grunt-contrib-jshint');
// grunt.loadNpmTasks('grunt-contrib-uglify');
// grunt.loadNpmTasks('grunt-contrib-less');
// grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ["jshint","watch"]);
};
tutto ok, ma mi trovo questo errore
Running "jshint:build" (jshint) task
app/scripts/app.js
line 1 col 1 Use the function form of "use strict".
line 11 col 1 'angular' is not defined.
app/scripts/controllers/about.js
line 1 col 1 Use the function form of "use strict".
line 10 col 1 'angular' is not defined.
app/scripts/controllers/main.js
line 1 col 1 Use the function form of "use strict".
line 10 col 1 'angular' is not defined.
‼ 6 warnings
Warning: Task "jshint:build" failed. Use --force to continue.
Aborted due to warnings.
io ho provato a inserire nella root del progetto nel file .jshintrc la proprietà globals per angular, ma non cambia nulla. Facendo un search dalla root vedo che esistono una decina e più di questi file, quindi io ho inserito correttamente nel file giusto la voce di globals???
file .jshintrc
codice:
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"globals": {
"angular": false
}
}