sage icon indicating copy to clipboard operation
sage copied to clipboard

Source Maps being written twice

Open kalenjohnson opened this issue 11 years ago • 16 comments

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

kalenjohnson avatar Mar 16 '15 22:03 kalenjohnson

Confirmed

stueynet avatar Mar 18 '15 02:03 stueynet

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'
          ]
        }
      })

retlehs avatar Mar 18 '15 05:03 retlehs

UPDATE: Not fixed. Same issue as slobich below

stueynet avatar Mar 18 '15 11:03 stueynet

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.

slobich avatar Mar 18 '15 11:03 slobich

Not fixed. Same issue as slobich above!

thebatz avatar Mar 18 '15 12:03 thebatz

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"
  }
}

retlehs avatar Mar 18 '15 17:03 retlehs

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.

stueynet avatar Mar 18 '15 18:03 stueynet

no, i don't — stock gulpfile. just to confirm, you ran npm install after making the change to package.json?

retlehs avatar Mar 18 '15 18:03 retlehs

Yup. When that did nothing I also ran npm update.

stueynet avatar Mar 18 '15 18:03 stueynet

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 avatar Mar 18 '15 18:03 stueynet

@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

kalenjohnson avatar Mar 18 '15 18:03 kalenjohnson

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.

slobich avatar Mar 18 '15 18:03 slobich

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.

slobich avatar Mar 18 '15 18:03 slobich

Yup confirmed. Sorry about my ignorance. First delete node modules and then npm install works.

stueynet avatar Mar 18 '15 18:03 stueynet

As stueynet stated, First delete node_modules and then run nom install worked perfectly !

psaac avatar Mar 21 '15 08:03 psaac

confirmed that fix works. Delete node_modules first.

BrunoFenzl avatar Mar 23 '15 11:03 BrunoFenzl