kozy4324 / grunt-concat-sourcemap Goto Github PK
View Code? Open in Web Editor NEWConcatenate files and generate a source map file.
License: MIT License
Concatenate files and generate a source map file.
License: MIT License
nevermind. Found my typo. No issue here.
Background: I currently run my grunt build at the full app (server+client) root, so that i can have Maven (via frontend-maven-plugin) run the grunt build on the CI server and thereby avoid checking grunt build artifacts into git.
The result, given our server setup, is that all css and js live (and are built) under a 'src/main/resources/static' directory/path. This directory is not part of the deployed path, but nonetheless ends up in the sourcemap file paths, thereby making the browser unable to find the source files listed in the map. To say it another way, the css ends up correctly at 'http://server/css/result.css', the map ends up correctly at 'http://server/css/result.css.map', but the sources are listed in the map as 'src/main/resources/static/css/source.css' instead of just 'source.css'.
I need an option to truncate the 'src/main/resources/static/css' off of the file paths. Any ideas?
The paths for source map files aren't proceeded correctly on windows.
They include backslashes instead of slashes, and the maps aren't working.
I use this:
concat_sourcemap: {
target: {
files: {
'path/output.js': ['another-path/**/*.js']
}
}
}
After running grunt i get an output like this:
{
"version": 3,
"file": "output.js",
"sources": [
"src\\file.coffee"
],
"names": [],
"mappings": "..."
}
Uglify has an option for --in-source-map to generate a source map based on JavaScript that's already compiled from somewhere else. Is there a reason to support that feature in grunt-concat-sourcemap? (Or does it already exist, and I've overlooked it?)
I'm trying to use a grunt-concat-sourcemap task after a grunt-browserify task but I'm getting a warning as grunt-concat-sourcemap is trying to use the encoded string as a filename to open.
Browserify embeds the source map as a base64 encoded string, i.e: data:application/json;base64
.
Could this plugin detect the embedded source map, decode it and use it directly?
Since the last release many changes has been added. I think is good to make a new release tag.
I was reading the mozilla documentation and came across sourcesContent: Optional. An array of contents of the original source files.
Would it be feasible to add an option to grunt-concat-sourcemap so that sourcemaps could be entirely self contained, including the mappings and the original sources? The reason I think this would be useful is that it would simplify server-side configuration and avoid having to upload original src files along with the map; unless I'm misunderstanding the purpose of soucesContent
Thoughts?
When my source code is in a path with spaces, e.g. "Source Code", this task fails with the following output:
Running "concat_sourcemap:scripts" (concat_sourcemap) task
[D] Task source: /.../node_modules/grunt-concat-sourcemap/tasks/concat_sourcemap.js
Warning: Unable to read "Source%20Code/app.litcoffee" file (Error code: ENOENT). Use --force to continue.
concat_sourcemap options:
{
sourcesContent: true
}
Since my sourcemap must be relative to the web root, I want to manually set my sourceMappingURL (ie /# sourceMappingURL=scripts.js.map
). sourceRoot
doesn't seem to do this.
This may be beyond the scope of what you're doing but I thought I'd propose it anyway: add an option for sourceMap: false
that allows you to concatenate without generating a sourcemap.
I recognize this can be done simply by using grunt-contrib-concat
but it seems a little silly to have two plugins, especially since I'm concatenating / minifiying locally expressly for the purpose of mirroring production as closely as possible and thus it would be great to be using the same plugin too.
Happy to help implement; I just wanted to make sure that was interesting to you.
Target config:
concat_sourcemap: {
main: {
files: {
'./build/build.js': filesToBuild
},
options: {
sourceRoot: './build/tmp/lib',
sourcesContent: true
}
}
},
Error message:
Warning: "build/tmp/lib/ d:/path-to-project/build/tmp/lib/somefile.js" is not in the SourceMap. Use --force to continue.
In this example, I have two grunt tasks. The first, compiles Sass files to CSS, generating sourcemaps. The second concatenates the generated CSS files with grunt-concat-sourcemap. My output sourcemap is the following:
{
"version": 3,
"file": "app.css",
"sources": [
"app/stylesheets/one.scss",
".tmp/stylesheets/one.css",
"app/stylesheets/two.scss",
".tmp/stylesheets/two.css"
],
"names": [],
"mappings": "AAAA;ACCA,K;ACDA;ACCA,K",
"sourcesContent": [
null,
".one{font-weight:bold;}.uno{font-style:italic;}\n/*# sourceMappingURL=one.css.map */",
null,
".two{font-weight:bold;}.dos{font-style:italic;}\n/*# sourceMappingURL=two.css.map */"
]
}
Most obviously, the sourcesContent
for the *.scss source files is null. But it seems that there's no reason (in this case) for the *.css source files and their sourcesContent to be included in the sourcemap.
I understand that this doesn't represent all cases - in some cases there may be a necessity to merge the input sourcemap with "original" source mappings from a single file, though it's hard for me to imagine this in practice. That said, I'm curious if there may be a way to exclude the *.css sources if there's nothing to merge.
Test! Test! Test!
It is necessary to configure automation test with multiple Node environments.
The configuration examples shows:
files: {
'dest/default_options.js': ['src/a.js', 'src/b.js']
}
as the syntax for specifying the source and destination files when it should be:
'dest/default_options.js': ['src/a.js', 'src/b.js']
At least that's what I had to use in order to get things working.
I may just be missing a configuration line, but from the code it looks like on line 79 the output is always:
sourceNode.add('//@ sourceMappingURL=' + mapfilepath);
This does not work for CSS files. It instead should output:
/*# sourceMappingURL=master.css.map */
Which works in Chrome.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.