gruntjs

How can I use the grunt-express for express 4.12?

江枫思渺然 提交于 2019-12-11 10:17:14
问题 I use the Express 4.12 to build my project and I want to use grunt-express to start my application. I have known that Express 4.12 start the application via node ./bin/www, so I write the Gruntfile.js like this: express: { dev: { options: { port: 3000, bases: path.resolve('bin/'), server: path.resolve('bin/www') } } } grunt.loadNpmTasks('grunt-express') grunt.registerTask('default', ['express', 'express-keepalive']); Unfortunately, when I run grunt, it reports an error: Fatal error: Server

Grunt connect proxy rewrite not works in https

随声附和 提交于 2019-12-11 10:16:28
问题 I try to create a connect proxy by this article. Almost everything is the same in my code, but I need to call something across https protocol. connect: { options: { port: 9000, hostname: '0.0.0.0', livereload: 35729 }, proxies: [{ context: ['/foo/product', '/foo/somethingelse'], host: 'non-https-domain.com', changeOrigin: true rewrite: { '^/foo': '' } },{ context: '/productImages', host: 'https-domain.com', https: true, port: 443, // just trying changeOrigin: true, rewrite: { '^/productImages

Replace a block of html with another block of html using grunt

拥有回忆 提交于 2019-12-11 10:09:30
问题 I have a block of html something like this - <div class = "logo"> <a href = "homepage.html"><img src = "logo.png"></a> <nav><a href = "#"> Sign In </a></nav> </div> I am automating my html template using grunt. All I want is, when I run grunt task it replace <a href = "homepage.html"><img src = "logo.png"></a> with {{logo}} so that the final html will become <div class = "logo"> {{logo}} <nav><a href = "#"> Sign In </a></nav> </div> Any type of help will be appreciated. Thankx. 回答1: Try to

Handlebars not loading after Require.js optimization with grunt-requirejs

↘锁芯ラ 提交于 2019-12-11 10:08:58
问题 I'm using the Yeoman Backbone generator for my app. I wanted to use Handlebars for templates. When I include a shim, it works great in development with grunt serve . // main.js require.config({ shim: { bootstrap: { deps: ['jquery'], exports: 'jquery' }, handlebars: { exports: 'Handlebars' } }, paths: { jquery: '../bower_components/jquery/dist/jquery', backbone: '../bower_components/backbone/backbone', underscore: '../bower_components/underscore/underscore', bootstrap: '../bower_components

Conditional Processing in HTML / JS with Grunt

青春壹個敷衍的年華 提交于 2019-12-11 09:57:41
问题 I'm working on an AngularJS app. I'm building this app with Grunt. I have three Grunt tasks: dev, test, and release. I would like to conditionally reference some JavaScript files in each case. For instance, I'd like to do something like this: index.html <!-- if task === 'dev' --> <script type="text/javascript" src="/js/script.dev.js"></script> <!-- else if task === 'test' --> <script type="text/javascript" src="/js/script.test.js"></script> <!-- else --> <script type="text/javascript" src="

“404 (Not Found)” for “polymer.min.js”

僤鯓⒐⒋嵵緔 提交于 2019-12-11 09:49:47
问题 I still got the same error as described here: "Uncaught Reference Error: Polymer is not defined" caused by IP-change? But after I uninstalled and reinstalled yeoman, grunt, bower and polymer-generator, fresh initialized Polymer-projects work fine now. My old Polymer-projects still have the same Error. I am using the newest versions for all tools mentioned above. (Grunt: 0.4.5, Bower: 1.3.9) 回答1: After all it seems like the problem was somehow caused by Polymer. I switched to the newest

Make watch not break down on error thrown by grunt-express-server

时光怂恿深爱的人放手 提交于 2019-12-11 09:48:18
问题 I use Yeoman to do some angular development with grunt, livereload etc. I've also set up a basic node.js/express app and I'm sharing some JS between the client (angular) and the server (node) using grunt-contrib-copy and grunt-express-server that fires on every file-save using watch. So far so good! The problem is if I introduce a syntax error into the code that I want to share with node and hit save. The syntax error gets shown in the log and breaks/stops the watch. Then I have to go restart

Run a command after a grunt task finishes?

别来无恙 提交于 2019-12-11 09:37:11
问题 I want to run a command but after a task finishes in grunt. uglify: { compile: { options: {...}, files: {...} } ?onFinish?: { cmd: 'echo done!', // or even just a console.log run: function(){ console.log('done!'); } } }, Either run a command in shell, or even just be able to console.log . Is this possible? 回答1: Grunt does not support before and after callbacks, but next version could implement events that would work in the same way, as discussed in issue #542. For now, you should go the task

How do I implement assertions in JavaScript?

旧时模样 提交于 2019-12-11 08:59:56
问题 I'd like to use assertions to check for invalid parameters in my private methods (and others that should only be called internally). I'd prefer: A failed assertion terminates the program, or at least stops my automated tests. console.assert() doesn't appear to do this. Assertions can be stripped out during production deployment (I'm using Grunt). A very minimal solution (shouldn't need a library to do this). EDIT: I'm not trying to test anything here. If my motivation for doing this is

How to run Grunt Build task by cliking on button through browser?

假装没事ソ 提交于 2019-12-11 08:00:01
问题 I have made one build process through grunt and it works fine from command prompt. Now I have a application from where i want to run this task by clicking build button. So is there any way i can rung grunt task from browser by writing any js or php script? If any further clarification needed do let me know. Thanks. 回答1: I see two options: Server-side script - like PHP, Python, etc. that launches your task. A browser plugin that uses native libraries (Start an external application from a