Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [yoeman] yo angular non funziona mai i task grunt!

    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

    codice:
    yo 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
      }
    
    }
    Luca Bottoni's World
    www.bottonisworld.com

  2. #2
    Se usi il generatore di Yeoman ti conviene mantenere anche il loro Gruntfile. Devi far partire il task serve dalla root del progetto, con
    codice:
    grunt serve
    e il tutto dovrebbe funzionare, anche senza la necessità di correggere i path degli script inclusi da bower.
    http://www.youtube.com/user/alekosfilini @afilini

  3. #3
    Ciao, provato oggi con nuova generazione di un yo angular.

    C:\wamp\www\angulartest>grunt serve
    Running "serve" task

    Running "clean:server" (clean) task

    Running "wiredep:app" (wiredep) task
    Warning: ENOENT, no such file or directory 'C:\wamp\www\angulartest\app\bower.json' Use --force to continue.

    Aborted due to warnings.


    Execution Time (2015-08-28 07:32:22 UTC)
    loading tasks 15ms ■■■■■■■■ 5%
    wiredep:app 258ms ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 94%
    Total 274ms
    il file bower è presente nella root e non nella cartella /app, però ho idea che se lo sposto, poi si incazza comunque
    Luca Bottoni's World
    www.bottonisworld.com

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.