I want to use Google Closure Compiler(GCC further) for joining my js-files and compressing before deploy. It's ok, if I will need to run some script. But how can I write a file with options for GCC? I can only write a *.sh file with task.
Help me please. Also it will be great, if there is some tool, that can watch for changes in my local js folder and run that task.
Thanks.
There are lots of "make" systems that provide a command to rebuild your software according to a set of rules when one of the source files changes. GNU/Linux has make, Java has ant, CoffeeScript has cake, Ruby has rake, etc. Any of these can spawn a task that will compile your .js files. They all have fiddly syntax.
A system that detects file changes and automatically rebuilds, tests, and deploys everything when files change is called a "continuous build", "continuous integration", or "continuous deployment" system. The big one is Jenkins developed for Java.
It sounds like you want a fairly simple single-user combination of 1 and 2.
node.js is well-suited to running a job that watches for file changes and spawns build commands. It doesn't have a "standard" JavaScript build system or continuous integration system. But there are lots of projects out there, such as
ready.js
drip for node.js got a lot of coverage but I'm not sure its status.
the CoffeeScript language (that compiles into JavaScript) has a Cakefile system that can watch for script changes and run commands
I'm trying to decide between ready.js and Cakefile myself.
check out plovr. http://plovr.com/
You need to get node.js so you can write make files in javascript , that's the best way to do it.
Related
I am trying to build dlib for webassembly using emscripten but I am not sure how to do so.
Currently, dlib generates executables and not bytecode which is needed for emscripten. Is there some way to get around this issue?
Currently this is what i am doing (from within the dlib-19.4 folder.
cd examples
mkdir build
cd build
cmake ..
emmake make
for the next step, I need to input a bytecode file however, dlib seems to just generate executables which the emcc command will not accept.
From what I can read from Dlib's documentation is that it has a lot of features that emscripten does not provide including threading and so on. So you will need to exclude functionality thats not supported.
Also referring to How to Compile section, it mentions how to use Dlib without Cmake.
It has a simple gcc example for SVM.
You should probably use this approach ie include the appropriate dlib headers in your project, write your functions and expose them for emscipten.
Then after building the js file you should be able to call the "exposed" functions from JS.
We are currently building our frontend js codebase (angularjs) using nodejs with grunt, which seems to be a popular setup, but we are not happy with this solution. Does anyone have suggestions for a build setup for e.g. linting, minimizing our js, running less, etc (in addition to some custom steps for angular in general and for our application specifically) without using nodejs at all?
I would leave it at that to avoid starting a flamewar, but here are, for context, some of the shortcomings of the current setup in our view:
grunt does not have even the basic functionality of a 1970s build system, like automatically re-building only files that have been modified based on file modification time
npm is causing constant headaches running on our build servers at every build
If grunt does not have even the basic functionality of a 1970s build system, why won't you use a 1970s build system then?
Just use make if that's what you're happy with. It still works fine. There's no reason not to use it if it you're satisfied with how it works.
I upgraded to the latest TypeScript recently and have found that the JavaScript is no longer being generated in Visual Studio (2013) if there are any TypeScript type errors. Is there a way to tell TypeScript to ignore type errors? I'm cleaning up a project and would like to work my way through it incrementally.
This might not be the answer you are looking for, but it is the best for your scenario in my opinion: I think you'd be better off using a task runner (such as gulp, grunt, etc) that watches your files and compiles on the fly. It will ignore the IDE and do what you want it to do.
If you're using Visual Studio 2013, you can first install Task Runner. This allows you to run them inside a window in your IDE.
Then you'll want to setup your project using the given task runner of your choice and creating a task for it. Ted Patrick has an example using gulp here. Depending on the size of your project you might want to use TypeScript's incremental compilation features too.
I use that setup in VS13 and I couldn't be happier. Every time I save a TS file it is recompiled (regardless if it's considered valid by the IDE or not) and I see the errors right there. You can see what it looks like in this screenshot, and the VS13 project/task runner script is available on GitHub if you need a reference.
(If you don't want to be hassled with figuring out a task runner, the compiler (tsc.exe) has a -w command line argument that does all the watching too. You could just create a batch file that you fire once and run on the background.)
Even if VS13 has "native" ways to watch and compile a .ts file, I'd definitely recommend using something like this instead. It decouples your project from the IDE and gives you (or anyone else) the ability to easily compile your project from anywhere, as well as also use whatever other tasks you think are necessary when building the project.
Now I make my protractor to work. Then I have another question: How to package the spec files and all the dependencies into one file, such as rpm or other format, so I can easily install it on another machine to run it? I searched the Internet and found some tools to package the javascript and CSS and images used in web page. But in my case, I only need to package the javascript I write to do the testing to one file.
I appreciate any suggestions.
The short answer is that's not possible.
When you run protractor on a fresh machine you need to have
an instance of selenium-webdriver server running (with all the browsers you want to test)
nodejs
But, assuming that the new computer you run protractor in has nodejs and selenium-webdriver is set up (i.e. either the local computer has it running, or you're testing over network like using saucelabs), then I guess you can zip up the file to send as one file.
As the title says I'm trying to automatically compile the public static coffeescript files on page load, rather than having to compile them myself and use the .js files, how might I achieve this, I'm trying to maintain a full CoffeeScript stack, this is the only thing I'm having trouble figuring out.
tl;dr: Read the title of the post.
There are a number of ways to accomplish what you're trying to do. Two of the easiest that I know of:
Use the connect-assets module. The idea behind this is that you have an /assets folder in the root, and you instantiate it with express.static, as you normally would with your /public folder. In there, you have two more folders: /js and /css. Your CoffeeScript goes in your /js folder. Then, from within your view template, just call js('yourfile'). It's a wonderfully simple module, but isn't the most advocated asset pipeline.
Use asset-rack. While not as simple to grasp as connect-assets, it's very flexible and is easy to extend. It would be the closest comparator to Rails' asset pipeline and is used by most of the popular JS frameworks (like Sails.js).
However, I would really advise that you refrain from on-the-fly compilation of assets, as it can really drain server performance.
It would be way better to compile on file save using a build system - CoffeeScript ships with Cake, so you can define a watch/compile/build/concatenate step right in your Cakefile and all it would take for you to compile on file save is to type $ cake watch in to the terminal before you change any code.
Alternatively you could write code, then $ cake build. Whichever you prefer. I might also add that cake-flour takes all of the pain out of writing Cake tasks.
coffee --watch --compile .
watches for files changes in . and compiles them as they change. Since you are using expressjs I think you would also like to restart the server as soon as a recompile happens:
coffee --compile --watch . &; nodemon server.js
which uses https://github.com/remy/nodemon
If you only want to have access to compiled CoffeeScript files over HTTP, you could also give connect-coffee-script middleware a try. It has worked quite well for me.
It has the advantage over using coffee --watch --compile that you don't need to have a separate program running.