Giter VIP home page Giter VIP logo

Comments (7)

basarat avatar basarat commented on June 15, 2024

At the point where people have other tasks people should perhaps learn and use grunt watch

from grunt-ts.

jeffmay avatar jeffmay commented on June 15, 2024

At first I was thinking that we could just let grunt-contrib-watch do the work by splitting up the code-gen and compilation into separate tasks, but after looking into the code, I can see why you want to perform the watching from grunt-ts. You can optimize some long running tasks better.

So I think the other direction of enlisting a watch program from within grunt-ts might be the best solution. It's pretty easy to call another task from within a task, so I was thinking we could hold a sequence of task names in memory and call all of them during the main watch loop. We would have 3 queues that you can register tasks,

  1. beforeCodeGen
  2. beforeCompile
  3. onComplete

I don't think we will need to get more granular than that. What do you think?

from grunt-ts.

basarat avatar basarat commented on June 15, 2024

I don't think we will need to get more granular than that

agreed 👍

from grunt-ts.

mthompson avatar mthompson commented on June 15, 2024

Has the enhancement been implemented that jeffmay suggested. I have need for such functionality. I would like to uglify after the compiling of all TypeScript files have completed. I attempted to do so using various combinations, but each failed, as uglify task never executes:

gruntfile.js

module.exports = function (grunt) {
// load the task
grunt.loadNpmTasks("grunt-ts");

// Configure grunt here
grunt.initConfig({
    ts: {
        // A specific target
        dev: {
            // The source TypeScript files, http://gruntjs.com/configuring-tasks#files
            src: ["app/**/*.ts"],
            // The source html files, https://github.com/grunt-ts/grunt-ts#html-2-typescript-support   
            //html: ["test/work/**/*.tpl.html"], 
            // If specified, generate this file that to can use for reference management
            reference: "app/reference.ts",
            // If specified, generate an out.js file which is the merged js file
            out: 'app/app.cmb.js',
            // If specified, the generate JavaScript files are placed here. Only works if out is not specified
            //outDir: 'test/outputdirectory',
            // If specified, watches this directory for changes, and re-runs the current target
            watch:'app',
            // Use to override the default options, http://gruntjs.com/configuring-tasks#options
            options: {
                // 'es3' (default) | 'es5'
                //target: 'es3',
                // 'amd' (default) | 'commonjs'    
                //module: 'commonjs',
                // true (default) | false
                sourceMap: true,
                // true | false (default)
                declaration: false,
                // true (default) | false
                removeComments: true
            }
        },
        uglify: {
            options: {
                mangle: true,
                compress: true,
                banner: '/*! Copyright 2014 - Me ' +
                    '<%= grunt.template.today() %> */'
            },
            build: {
                src: ['app/app.cmb.js'],
                dest: 'app/app.cmb.min.js'
            }
        }
    },
    watch: {
        files:  "app/**/*.ts",
        tasks:['ts:dev']
    },
    watchUglify: {
        files:  "app/**/*.ts",
        tasks:['ts:uglify']
    }
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');

// Rename watch to watchUglify and load it again to attempt to run multiple tasks using watches
grunt.renameTask('watch', 'watchUglify');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', ['watch']);
grunt.registerTask('dev', ['watchUglify']);

}

<< gruntfile.js

Please advise and/or provide an example solution towards this issue.

from grunt-ts.

jeffmay avatar jeffmay commented on June 15, 2024

The problem I had was actually with grunt-ts-watch. It has a bug where you can run grunt watch to watch all tasks simultaniously or grunt watch:ts but you can't define a task that is grunt.registerTask('watch-ts', ['watch:ts', 'watch-html']). Watch is all or one or nothing. I needed to watch 2 things but not all.

In your case, I think you just need to run watch: { tasks: ['ts:dev', 'ts:uglify'] }

from grunt-ts.

mthompson avatar mthompson commented on June 15, 2024

--- In your case, I think you just need to run watch: { tasks: ['ts:dev', 'ts:uglify'] }

tried that::
image

ts:dev runs fine, however, you will notice in the screenshot above, ts:uglify never executes.

from grunt-ts.

jeffmay avatar jeffmay commented on June 15, 2024

That's strange. What happens if you do grunt.registerTask('buildUgly', ['ts:dev', 'ts:uglify'])?

Are you sure it isn't a problem with grunt-contrib-watch running multiple tasks?

from grunt-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.