grunt-contrib-uglfy minified file not working - javascript

i'm new to angularjs as well as grunt. I'm using "grunt-contrib-uglify": "^1.0.1" to uglify javascript files and place them into one file i'm getting corect output file as expected. but when i use it in html file getting module inject error.
I tried for uglifying individual file seperately used them in html file worked perfectly as expected without any error.
I also tried for grunt-contrib-concat and use its output to uglify but result is same (module inject error).
It means when i place multiple javascript files in to one file, angular is not creating injector for my application.
can anybody explain what is happening here?

Related

How can I run this JavaScript file?

I have this project:
but I don't know how to run the generate_js.js in my browser so I can see use console.log inside of the file.
The whole purpose of this project is to run generate_js.js, which is then supposed to generate an icon.js file which contains the svg icons in a particular object format/structure. But what happens when I run generate_js.js is that a folder generate_js is created with all the icons as js files, and each file has an export statement.
I am trying to understand how is all of this working, but I can't. I need to be able to see what's happening on my browser. I need to use console.log to see, but I don't know how to run this project on my browser. There is no index.html file, and when I created one, and linked the project_js.js with a script tag, I keep getting Uncaught ReferenceError: require is not defined error.
How can I run this JavaScript/project on my browser?
Here's the relevant part of package json:
Note: This project is installed as a dependency inside another project, and inside the node_modules, there's a dist folder which contains the icons.js file that I referred to. In it, all the icons are created as objects. I need to change the way the object structure a bit, so I need to understand how are they generated by this generate.js file, but I need to be able to console.log what's happening inside the file.

Ember: How do I add a file into the treeForAddon after postBuild?

I have a case where I am using node-sass functions to generate a JS file after sass has completed compiling. I am outputting the file into the addon/utils directory; however, the file is not being picked until the project is built the second time.
I feel this would easily be solved if I ran SASS first and then compile the JS next (after trees have been updated with the new JS file), but I can't find anything that does that.
Any suggestions on how I could make this work?

Minified file does not use minified module

I have a node.js folder which contains a main js file and several other js files which contain the functions that the main js file will import.
I have minified all the js files in this folder.
In the original main.js file, it calls another module with the following line;
var func= require('./func');
After minification, this line remains the same. However, func.js is changed to func.min.js after minification. Do I have to modify the minified file manually to have it import func.min.js this way?
var func= require('./func.min');
It is quite tedious to manually make changes to the minified file. What is the most efficient way to minify my js files and get the main.min.js working?
I am using Webstorm file watchers to minify the js files.
To get your main.js working, change the require line in main.js to;
var func= require('./func.min');
This will work because you are using Webstorm file watchers to minify the js files. Therefore, when func.js is changed, func.min.js will be automatically generated.

Bootstrap 3.1.1: I can't import all the bootstrap .js files, how is "= require" supposed to work?

I am using the latest Bootstrap v3.1.1 Sass.
Within the .zip file, I get
lib, tasks, templates, test and vendor.
I ignored everything and only use the vendor > assets folder.
The assets folder has all the fonts, stylesheets and javascripts I need.
I have gotten the file structure setup properly.
However when I am trying to import .js files from the javascript folder, I am having a bit of a problem.
Unlike the bootstrap.scss file that comes along. I can just uncomment the _.scss file that I need and it will work.
Within the bootstrap.js file, it contains some syntax that I haven't seen before. After a bit of Google, it says 'require' is a nodejs syntax.
I uncommented a few and try to see if they work. However it fails. the .js file I got back is exactly like the above screenshot. It doesn't concatenate modal.js, tooltip.js and popover.js. I did abit of Google, it says I need to have RequireJs?

Compiling CoffeeScript from Multiple Files

Im looking for a way to compile all of my coffeescript files, currently in individual files such as features.coffee // scroll.coffee etc etc, in to one main outputed .js file.
Im using an application.coffee file at current to act as the main file. Ive imported my various files using:
#= require features.coffee
#= require scroll.coffee
However when Im outputting the application.coffee to application.js on the code from within the application.coffee is outputting and not that of the imported files
Im assuming that coffeescript imports are not native features and that some sort of plugin will be needed
Thanks in advance
You have to manually merge the source files into a main script file ( aka concatenate them ), then compile to JavaScript. You have not specified what you are working with, but in node.js, the require function only executes an external script ( to put it very simply ), it does not place the source code into current file as you seem to be expecting.
There are many tools on the network to concatenate your source code into a single main script - just google around and find what suits you best.

Categories

Resources