tssajo / Minify

Minify for Sublime Text allows you to quickly minify and/or beautify CSS, JavaScript, JSON, HTML and SVG files -- compatible with ST2 and ST3
Other
93 stars 16 forks source link

CSS source maps contain absolute paths with extra slashes in sources object #56

Closed klined closed 6 years ago

klined commented 7 years ago

Hello. I love this plugin. You've done awesome work!

I am having a small problem though. When I minify my CSS files, my source map's sources object looks like this: {"version":3,"sources":["L:\\path\\to\\file\\file.css"],"names":[],"mappings":"..."}

I need the sources object to not contain the path. Am I missing an option to prevent this from happening somewhere?

klined commented 7 years ago

Although this probably is not the most elegant solution, I inserted these lines into the css section of the minify function in MinifyClass to change to the directory of the css file being minified:

... else: cwd = os.getcwd(); inpdir = re.sub(r'(\\[^\\]+)$', r'', inpfile, 1) os.chdir(inpdir+'\\') cmd = self.fixStr(self.get_setting('cleancss_command') or 'cleancss').split() ...

I also put this at the top of the minify function: def minify(self): inpfile = self.view.file_name() cwd = False ...

I also put this at the bottom of the minify function to switch back to the original directory: ... if cmd: print('Minify: Minifying file:' + str(inpfile)) self.run_cmd(cmd, outfile) if cwd: os.chdir(cwd)

This prevented the absolute path from being added to the entries in the sources object. I'm still hoping that there's some option that I missed.