Comments (7)
At the point where people have other tasks people should perhaps learn and use grunt watch
from grunt-ts.
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,
- beforeCodeGen
- beforeCompile
- onComplete
I don't think we will need to get more granular than that. What do you think?
from grunt-ts.
I don't think we will need to get more granular than that
agreed 👍
from grunt-ts.
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.
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.
--- In your case, I think you just need to run watch: { tasks: ['ts:dev', 'ts:uglify'] }
ts:dev runs fine, however, you will notice in the screenshot above, ts:uglify never executes.
from grunt-ts.
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)
- grunt-ts hangs forever HOT 3
- TypeError: Cannot read property '_writeln' of undefined HOT 6
- help
- resolve paths relative to tsconfig.json HOT 6
- Module resolution fails when used Path mapping HOT 1
- Please publish a new version for grunt-ts in NPM HOT 1
- Mention that we do not support `paths` in the readme
- baseUrl not passed to tsc correctly when using "." in tsconfig.json HOT 5
- Error running grunt-ts from VS2015 after update to typescript 3.1.1 HOT 2
- Compile error HOT 1
- Need to support grunt v1.0.2 HOT 6
- alwaysStrict not read from tsconfig.json HOT 1
- Lodash prototype pollution vulnerability HOT 1
- Support for Project References HOT 3
- grunt-ts does not work with empty "types" array in tsconfig.json HOT 2
- error TS2732 ...Consider using '--resolveJsonModule' to import module with '.json' extension HOT 1
- Override tsconfig with command line
- update dependency chokidar to fix Regular expression denial of service glob-parent HOT 2
- options.process is undefined, even though it's defined. HOT 1
- Take over as maintainer HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-ts.