Source Maps being written twice
https://discourse.roots.io/t/sourcemaps-no-longer-working-as-expected-with-sage-update/3022
I just confirmed with a fresh Sage install that the source maps are being written directly into the main.css file as well as the main.map.css file.
Diffing a project that's not having the issue, the only difference in the gulpfile.js is this:
< gulp.watch(['bower.json'], ['wiredep']);
---
> gulp.watch(['bower.json', 'assets/manifest.json'], ['build']);
Doesn't seem connected, since it's in the watch task
Confirmed
trying to debug. disabling pleeease's minification makes the sourcemap work as expected:
.pipe($.pleeease, {
minifier: false,
autoprefixer: {
browsers: [
'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4',
'opera 12'
]
}
})
UPDATE: Not fixed. Same issue as slobich below
disabling pleeease's minification doesn't fix the issue for me. it does change the way source maps work. before the source maps referenced only the first line of the main.css. now they reference the .less files but the line numbers and in some cases even the .less files are off. IE: if i add background-color: red; to <body> in _global.less the source maps points me to grid.less:43 and the source map still get's compiled in main.css in the sourceMappingURL as base64 encode.
Not fixed. Same issue as slobich above!
switching to pleeease 3.2.0 works for me. add the following to your package.json's devDependencies:
"pleeease": "3.2.0",
example of full package.json:
{
"name": "sage",
"version": "8.1.0",
"author": "Ben Word <[email protected]>",
"homepage": "https://roots.io/sage/",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/roots/sage.git"
},
"bugs": {
"url": "https://github.com/roots/sage/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
],
"scripts": {
"build": "bower install && gulp",
"jshint": "gulp jshint",
"jscs": "jscs gulpfile.js assets/scripts/*.js"
},
"engines": {
"node": ">= 0.12.0",
"npm": ">=2.1.5"
},
"devDependencies": {
"pleeease": "3.2.0",
"asset-builder": "^1.0.1",
"browser-sync": "^2.0.1",
"del": "^1.1.1",
"gulp": "^3.8.10",
"gulp-changed": "^1.1.0",
"gulp-concat": "^2.3.4",
"gulp-flatten": "0.0.4",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.0.0",
"gulp-jshint": "^1.8.4",
"gulp-less": "^3.0.1",
"gulp-load-plugins": "^0.8.0",
"gulp-pleeease": "^1.1.0",
"gulp-plumber": "^1.0.0",
"gulp-rename": "^1.2.0",
"gulp-rev": "^3.0.0",
"gulp-sass": "^1.2.4",
"gulp-sourcemaps": "^1.1.1",
"gulp-uglify": "^1.0.1",
"imagemin-pngcrush": "^4.0.0",
"jshint-stylish": "^1.0.0",
"lazypipe": "^0.2.2",
"merge-stream": "^0.1.7",
"traverse": "^0.6.6",
"wiredep": "^2.1.0",
"yargs": "^3.2.1"
}
}
Do you still have minifier: false,? Just updating pleeease din't fix it on my end. Actually neither works for me at all. A few elements map to the right place but for the most part its basically random.
If I don't have minifier: false, within gulp it actually just says every class is from font-awesome.css which i installed via bower.
no, i don't — stock gulpfile. just to confirm, you ran npm install after making the change to package.json?
Yup. When that did nothing I also ran npm update.
Just to be a bit more verbose...
On a plain vanilla sage install, I get main.css as the source of all styles. To reproduce:
Install WP add define('WP_ENV', 'development'); to wp-config.php Pull Sage npm install and bower install activate theme add body{background: black} to _global.less run gulp view site inspect body source shows main.css:1
@stueynet I wouldn't run npm update, I would delete the node_modules folder and run npm install again.
So along with your instructions, you need to add "pleeease": "3.2.0", to package.json, above "gulp-pleeease": "^1.1.0",, before running npm install
working for me. but it didn't work with npm install or npm update. i had to manually delete node_modules folder (and i deleted dist folder as well) and then run npm install. tried it on two local sites. one with Sage 8.1.0 and one with 8.0.1 and it's working on both. and it's fixed both issues: source map compiled in main.css and source map wrong line/file reference.
just saw @kalenjohnson comment. so yes... i did it like he recommends. first deleted node_modules and then run npm install and it worked for me.
Yup confirmed. Sorry about my ignorance. First delete node modules and then npm install works.
As stueynet stated, First delete node_modules and then run nom install worked perfectly !
confirmed that fix works. Delete node_modules first.