angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Source map not working for SCSS files

Open rukshandangalla opened this issue 8 years ago • 87 comments

Recently I updated cli version 1.3.2 to 1.6.3 and after that I can't see scss source mapped file in developer tools in Chrome of Firefox .

Versions : 1.6.3

Angular CLI: 1.6.3
Node: 8.9.3
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cli: 1.6.3
@angular/language-service: 4.4.6
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

Repro steps

  • Create new angular app using ng new sample-app
  • Add scss file in angular-cli.json "styles": ["styles/styles.scss"]
  • Launch app using ng serve -sm -ec
  • Inspect styles using chrome dev-tools.

Observed behavior

No actual scss file, only style.bundle.css where all the styles compiled. image

Desired behavior

Actual scss file can be seen in the developer tools with the line number image

rukshandangalla avatar Jan 05 '18 03:01 rukshandangalla

@clydin any update on this?

rukshandangalla avatar Jan 08 '18 09:01 rukshandangalla

Source map not working for LESS files

I have the same issue with Less files too.

The component LESS files appear, but the styles brought in via the CLI are not.

Versions

Angular CLI: 1.6.2
Node: 6.11.2
OS: darwin x64
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.2
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.40
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.2
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0

michael-letcher avatar Jan 11 '18 15:01 michael-letcher

Dnia 5 stycznia 2018 04:42 Rukshan Lakshitha Dangalla <[email protected]> napisał(a): Recently I updated cli version 1.3.2 to 1.6.3 and after that I can't see scss source mapped file in developer tools in Chrome of Firefox . Versions : 1.6.3 Angular CLI: 1.6.3Node: 8.9.3OS: win32 x64Angular: 5.0.0... animations, common, compiler, compiler-cli, core, forms... http, platform-browser, platform-browser-dynamic... platform-server, router@angular/cli: 1.6.3@angular/language-service 4.4.6@angular-devkit/build-opt 0.0.36@angular-devkit/core: 0.0.22@angular-devkit/schemati 0.0.42@ngtools/json-schema: 1.1.0@ngtools/webpack: 1.9.3@schematics/angular: 0.1.11@schematics/schematics: 0.0.11typescript: 2.4.2webpack: 3.10.0 Repro steps Create new angular app using ng new sample-app Add scss file in angular-cli.json "styles": ["styles/styles.scss"] Launch app using ng serve -sm -ec Inspect styles using chrome dev-tools. Observed behavior No actual scss file, only style.bundle.css where all the styles compiled. zasobygwp.pl Desired behavior Actual scss file can be seen the developer tools with the line number zasobygwp.pl — You are receiving this because you are subscribed to this thread. Reply to this email directly, zasobygwp.pl view it on GitHub , or zasobygwp.pl mute the thread .

Sadlowski avatar Jan 13 '18 12:01 Sadlowski

I've found that it is actually working for me, but just not for Bootstrap.

We're building bootstrap manually and therefore not using the default bootstrap.less found in the LESS folder.

michael-letcher avatar Jan 15 '18 12:01 michael-letcher

It does not show references to my project's scss files nor to bootstrap 4's scss files. Only to styles.bundle.css.

smlombardi avatar Jan 17 '18 16:01 smlombardi

My issues is with Bootstrap 3 and LESS

I've got a bootstrap.less (copy from ~/bootstrap/less/bootstrap.less) in my app folder that I've added to the angular-cli.json

Which when I run ng serve -sm -ec -env=mock shows source maps for my components but not for my complied global less files imported from the angular-cli.json

So the fix they mention about removing ~ will not work for me...

michael-letcher avatar Jan 17 '18 16:01 michael-letcher

I am not even using ~ we use:

      "styles": [
        "../node_modules/prismjs/themes/prism.css",
        "../node_modules/@ngx-loading-bar/core/loading-bar.css",
        "../node_modules/ng2-toastr/bundles/ng2-toastr.min.css",
        "sass/designsystem/designsystem.scss",
        "styles.scss"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.slim.js",
        "../node_modules/popper.js/dist/umd//popper.min.js",
        "../node_modules/bootstrap/dist/js/bootstrap.js"
      ],

The css is complied and works for all of these, but no source maps.

smlombardi avatar Jan 17 '18 16:01 smlombardi

@smlombardi Yeah, seems like a bug from at least 1.6.2 onwards

michael-letcher avatar Jan 17 '18 16:01 michael-letcher

I've had this problem from 1.5 onwards

dhvidding avatar Jan 17 '18 18:01 dhvidding

As I can see many folks have this issue. What can we do about this?

rukshandangalla avatar Jan 21 '18 08:01 rukshandangalla

1.6.5 didn't solve the issue for me. (LESS)

michael-letcher avatar Jan 23 '18 07:01 michael-letcher

This is making it very hard to work and debug css styling issues.

smlombardi avatar Jan 23 '18 14:01 smlombardi

Same issue here when I upgraded from 1.4.7 to 1.6.5. Please fix, this is a major blocker!

anthonyartese avatar Jan 25 '18 21:01 anthonyartese

Still not working in 1.6.6, FWIW.

smlombardi avatar Jan 29 '18 15:01 smlombardi

I have same issue, and still wait for fixing. This is a critical issue, it blocks rapid development.

kamuran21 avatar Jan 31 '18 10:01 kamuran21

This is main reason why I am still using Angular 4 and cli 1.4.x in production and not upgrading to Angular 5.

dmijatovic avatar Jan 31 '18 10:01 dmijatovic

Some Context:

  • using angular-cli version 1.6.6
  • project is generated by the CLI.
  • using Scss

I remembered it was a weird thing in Webpack config where I had to add extra config to allow sourcemap (in addition to the plugin config).

Solution: In "node_modules@angular\cli\models\webpack-configs\common.js" file, in line 162, Add a line devtool: 'source-map', in the returned common configuration object in the getCommonConfig function, e.g.

    ...
    catch (e) { }
    return {
        devtool: 'source-map',        // add this line
        resolve: {
            extensions: ['.ts', '.js'],
             ...

Tested with the following Commands in terminal (also works with Sass @import):

ng serve           // no sourcemap
ng serve -sm -ec   // has sourcemap
ng serve --sourcemap --extract-css  // has sourcemap   
ng serve --sourcemap --extractCss   // has sourcemap   

CharltonC avatar Feb 06 '18 06:02 CharltonC

@chaeusler Not working for me, 1.6.7

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolve has an unknown property 'devtool'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, cacheWithContext?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }

smlombardi avatar Feb 06 '18 13:02 smlombardi

Proposed solution by @CharltonC works for me on v1.6.3 and v1.6.7 (two test projects I happen to have now). I am using scss @imports for bootstrap and material in styles.scss and I have proper source maps now. Exactly what I need. Thanks CharltonC!

dmijatovic avatar Feb 06 '18 17:02 dmijatovic

@chaeusler @dmijatovic Am I missing something? When I add the line recommended, I get the above error, in short configuration.resolve has an unknown property 'devtool'

This is a standard install of 1.6.7

smlombardi avatar Feb 06 '18 20:02 smlombardi