I am using grunt-contrib-requirejs to munge my files into a single file and generate a sourcemap. The sourcemap seems to be valid but is 6 lines off in the debuggers in both Chrome and Firefox. I have googled quite a bit but can't find any reasons why this would happen. Has anyone else come across a similar problem?
This is a very large project with about 200 files, i've c/p my grunt config for reference.
dev: {
options: {
baseUrl: 'assets/javascript',
optimize: 'none',
generateSourceMaps: true,
mainConfigFile: 'assets/javascript/requireconfig.js',
name: 'app',
preserveLicenseComments: false,
include: [
'plugins/dropdown-toggle',
'brand/modules/checkmate-init',
'brand/modules/batch-handler',
'brand/modules/dataset-editors',
'brand/modules/recording-editors',
'brand/modules/recording-state'
],
out: 'public/assets/js/myapp.js'
}
},
dist: {
options: {
baseUrl: 'assets/javascript',
optimize: 'uglify2',
generateSourceMaps: false,
mainConfigFile: 'assets/javascript/requireconfig.js',
name: 'app',
include: [
'plugins/dropdown-toggle',
'brand/modules/checkmate-init',
'brand/modules/batch-handler'
],
out: 'public/assets/js/myapp.js'
}
}
This could be related to an issue with https://github.com/requirejs/requirejs/issues/1054
Adding to r.js config:
skipPragmas:true
Did the trick for me.
r.js config:
https://github.com/requirejs/r.js/blob/2.2.0/build/example.build.js#L299
Related
I have written below code in gruntFile.js.
typescript: {
base: {
options: {
target: 'es5',
sourceMap: true,
noImplicitAny: true
}
},
default: {
files: [
{ src: 'source/tests/**/*.ts', dest: 'build'},
{ src: 'source/scripts/**/*.ts', dest: 'build'}
]
}
},
and I am trying to run "grunt typescript" command from command line. It is showing below error.
I have tryed "grunt typescript --force" command also. but still it is not working.
still it is not create build folder and it means that task is not working properly. Thanks in advance.
EDIT:- I have change my gruntfile.js to below as suggest in answer.
typescript: {
base: {
src: ['source/tests/**/*.ts'],
dest: 'build/',
options: {
target: 'es5',
sourceMap: true,
noImplicitAny: true
}
},
}
But still I am facing same problem.
Looking at the most current documentation that I could find for grunt-typescript, your syntax is wrong. I have a feeling that you actually want to be using grunt-ts. It's also the plugin I know of that is compatible with the syntax you've supplied.
My personal opinion: Use grunt-ts, it's been much easier to work with, and I've gone through a few iterations of trying out a bunch of tools to get to our current build environment.
I cannot seem to find an easy way to copy all the files from Polymer to using grunt-bower-task.
grunt.initConfig({
bower: {
install: {
options: {
targetDir: 'wwwroot/lib',
layout: 'byComponent',
install: true,
copy: true,
verbose: true,
cleanTargetDir: false,
bowerOptions: {}
}
}
}
I understand that only the main files defined inside each element's bower.json file get copied over. I am also aware that I could put a exportsOverride section in my own bower.json to include more files like this -
"exportsOverride": {
"*": {
"": "*.*",
"demo": "demo/*.*",
"test": "test/*.*"
}
}
But this doesn't cover all cases as some elements have more sub-folders than just demo and test. Do I have to manually look them all up and add their paths to the exportsOverride, or there's an easy way that I've overlooked?
hate to provide a sample of a fail....
FWIW recently , i had very similar issue ... worked it and failed
what i did is abandon the attempt to flatten everything out in the "dist" tag for a first polymer project. Rather i just ran minify/ugly on one or two elements leaving the HTTP2 type file structure ( deep and many many, dirs/files. )
// the process belo NG . Manual edit needed on "polymer-min.html" go end and chg the js file name
copy: {
main: {
files: [
// includes files within path
{expand: true, src: ['*html'], dest: 'dest/', filter: 'isFile'},
// includes files within path and its sub-directories
{expand: true, src: ['js/**', 'images/**' ,'css/**' ,'elements/**' ,'bower_components/**'], dest: 'dest/'},
{ src: ['tmp/csp/build-csp.html'], dest: 'dest/bower_components/cast-button-polymer/cast-button-polymer-min.html',
filter: 'isFile',
options: {
process: function (content, srcpath) {
return content.replace(/build-csp.js/g,"cast-button-polymer-min.js");
},
},
},
{ src: ['tmp/csp/build-csp-min.js'], dest: 'dest/bower_components/cast-button-polymer/cast-button-polymer-min.js', filter: 'isFile'},
],
},
},
I am attempting to use the grunt-contrib-less grunt task to compile my less files to css. What I would like to do is compile them inline, so that each .less file creates a single .css file.
Workflow:
1) Initial file system:
someFolder2
joe.less
rachel.less
someSubFolderA
jake.less
bob.less
someFolder4
someSubFolderB
ally.less
2) run grunt less
3) File system:
someFolder2
joe.less
rachel.less
joe.css
rachel.css
someSubFolderA
jake.less
bob.less
jake.css
bob.css
someFolder4
someSubFolderB
ally.less
ally.css
I have played around with various options but I can't figure out how to do this. Any suggestions would be greatly appreciated. This is the starting point grunt task I have been using:
less: {
paths: [
"src/someFolder2/**/*.less",
"src/someFolder4/**/*.less"
],
options: {
// outputSourceFiles: true
// compress: true,
// sourceMap: true,
// sourceMapFilename: "jake.txt"
// outputSourceFiles: true
}
}
This will (I think) concat all of the less files into a single CSS file.
You have to define task for grunt
options: {
paths: ["<%= cfg.dist %>/src/less"],
sourceMap: true,
rootpath: "<%= cfg.dist %>/",
relativeUrls: false,
cleancss: false
},
test: {
files: [
{
expand: true,
cwd: '<%= cfg.dist %>/src/less/',
src: ['*.less'],
dest: '<%= cfg.dist %>/build/css/',
ext: '.css'
}
]
}
/src/less/ - location of your less files
/build/css/ - folder where css will be generated
My livereload is "working" in that it live reloads the page when a file is changed, but only if I modify the file directly. If the file is generated through the grunt stylus or jade compiler, nothing happens.
When I look at grunt with verbose turned on, the Live reloading root.css... line appears only if I save root.css directly. If root.css is modified through the stylus compiler, the line does not appear. It's as if watch doesn't detect the file has been changed if it's changed through a compiler. This same issue occurs with jade as well.
Here's my stylus task (trimmed):
stylus: {
options: {
compress: false,
use: [
require('autoprefixer-stylus')
]
},
src: [
'app/styl/**/*.styl'
],
dest: 'build/css/root.css'
}
And here's my watch task (trimmed):
livereload: {
options: {
livereload: 1337,
},
files: 'build/**/*'
},
stylus: {
files: [
'app/styl/**/*.styl',
],
tasks: ['stylus:dev']
},
I really hope I'm just doing something stupid. I can't find any problems similar to this one.
EDIT:
Just in case this helps, I discovered that by changing my grunt task from running ['clean','jade:dev', 'stylus:dev', 'connect:dev', 'watch'] to only running ['connect:dev', 'watch'], livereload works as intended once, then never again. (Modifying the css directly still works though.)
EDIT 2:
I was able to fix this by adding livereload to each specific task in watch, like so:
livereload: {
options: {
livereload: 1337,
},
files: 'build/**/*'
},
stylus: {
files: [
'app/styl/**/*.styl',
],
tasks: ['stylus:dev'],
options: {
livereload: 1337
}
},
As to why this works, I have no idea. If anyone can shed some light on this, it'd be much appreciated. Though to be honest, I don't know why I didn't try this earlier.
I would like to exclude libs directory from being lint'ed. However, ignores in options and planted .jshintignore file in project directory won't make libs to be excluded.
jshint: {
options: {
smarttabs: true,
ignores: ['public/js/libs/**/*.js']
},
all: [
'Gruntfile.js',
'public/js/**/*.js'
]
},
grunt version:
grunt-cli v0.1.11
grunt v0.4.2
grunt-contrib-jshint#0.7.2
What did I miss out?
ignores is a jshint option and expects specific files. It's better to use the idiomatic Grunt negate ! to exclude files:
jshint: {
options: {
smarttabs: true
},
all: [
'Gruntfile.js',
'public/js/**/*.js',
'!public/js/libs/**/*.js'
],
},
See http://gruntjs.com/configuring-tasks#globbing-patterns