Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sourcemap path to dynamic file selection #432

Open
mikicof opened this issue Aug 23, 2016 · 0 comments
Open

Add sourcemap path to dynamic file selection #432

mikicof opened this issue Aug 23, 2016 · 0 comments

Comments

@mikicof
Copy link

mikicof commented Aug 23, 2016

Hi all,

Currently our project has multiple js files in multiple folders, so we are using dynamic file selection in our uglify process and sourcemaps creation for debugging.

Our uglify task is the following:

uglify: {
    build: {
        options: {
            sourceMap: true,
            sourceMapIncludeSources: true,
            compress: {
                sequences: true,
                dead_code: true,
                conditionals: true,
                booleans: true,
                unused: true,
                if_return: true,
                join_vars: true,
                drop_console: true
            }
        },
        files: [{
            expand: true,
            src: ['path/to/js/**/*.js'],
            cwd: '.tmp',
            dest: '.tmp'
        }, {
            expand: true,
            src: ['path/to/other/js/**/*.js'],
            cwd: '.tmp',
            dest: '.tmp'
        }]
    }
}

When we load the js along the page (using the common script tag at the header), the sourcemaps works properly, but when we load them by ajax it gives an 404 error.
That is because the sourceMappingURL of the js files are relative to the minified files and not the full path from root, so when the file is ajax loaded, it tries to load them from the document url which is wrong.

I think the best way to overcome this error is specifying the full path in the sourcemaps, but as the files are selected dynamically we cannot specify the path of any of them using sourcemaproot, and it isn't any method to specify it dynamically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant