magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Source maps are not being generated #9011

Open ClaudiuCreanga opened 7 years ago

ClaudiuCreanga commented 7 years ago

No source maps are being generated by grunt.

Preconditions

  1. vanilla magento2 installation 2.1.5, php7
  2. developer mode

Steps to reproduce

  1. dev/tools/grunt/configs/less.js has sourceMap: true
  2. run grunt exec and grunt watch
  3. change a less file
  4. grunt compiles the less files

Expected result

  1. Source maps should be created in the css folder in pub/static/... after grunt compiled less files

Actual result

  1. No source map being created
gillesMifsud commented 7 years ago

Did you find any solution to the sourcemaps not generated? EDIT: It happens to be the locales being different from the themes.js grunt config and the one set in back-office.

naraujobianchi commented 6 years ago

@ClaudiuCreanga @gillesMifsud I'm having the same problem with sourcemaps not generating on Magento 2.1.9. Is there a way to solve this? Thanks!

gillesMifsud commented 6 years ago

@ClaudiuCreanga make sure you target the same locale theme. The grunt config file themes.js locale and grunt php bin/magento dev:source-theme:deploy --type="less" --locale="fr_FR" --area="frontend" --theme="Vendor/theme" and you cleaned everything rm -rf var/di/* generated/code/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/* and cache flush before this.

c3D-Dan commented 6 years ago

Can we confirm please if this is an issue with 2.1.9? Im having the same issue. No source maps generated for CSS files. Tried all the steps above. Grub exec: Seems to complete without issue, my themes.js contains this

jarvis: { area: 'frontend', name: 'Vicomage/jarvis2', locale: 'en_AU', files: [ 'css/styles-m', 'css/styles-l' ], dsl: 'less' }, Im running the following command php bin/magento dev:source-theme:deploy --type="less" --locale="en_AU" --area="frontend" --theme="Vicomage/jarvis2" and have cleared all caches etc.

When I try to find and .map files, all I find is javascript map files

ihurskyi commented 6 years ago

What is the commit number of this fix in v.2.3 ?

kirmorozov commented 6 years ago

Hope, not in 2.3, feature freeze. @ihurskyi 2.4 for sure, I have uglified js with sourcem aps in production as well as SASS post-processed. Have to find time to wrap it up so it can be part of core. Bundling does not work as good as I want.

FYI this will require people to have nodejs/NPM as part of ordinary setup, and far deom

kirmorozov commented 6 years ago

Question for once who want it in 2.3.x there is a way to put it in the core. If node parts are found that are needed to make things work. Will use default behavior if nothing found. Who is ready to fill this gap June 12,16?

Krielkip commented 5 years ago

When using grunt less, and in themes.js the sourceMap: true, is set. Looking in the inspector i see a map, but link to the less file is not found (404)

Now the possible problem is that the magento2 public link is in /pub/ and the magento files in /. The link of the _[filename].less is going to /pub/static/ instead of /static/ So removing in the url the /pub/ part, shows the good less file.

In dev/tools/grunt/configs/themes.js can be found sourceMapRootpath: '/', Changing this with like /fooman/ changes the url to /fooman/pub/static/ Trying /../ does not work. It looks like the link will be ignored.

When setting your apache or nginx public link is set to the magento root, then the links works, because it loads /pub/static/frontend (and so on)

Leland commented 5 years ago

@Krielkip a workaround to this is to add outputSourceFiles: true, to the options config. That is:

    options: {
        outputSourceFiles: true,
        sourceMap: true,
        strictImports: false,
        sourceMapRootpath: '/',
        dumpLineNumbers: false, // use 'comments' instead false to output line comments for source
        ieCompat: false
    },
sunilit42 commented 5 years ago

@le0n4eg not working for me

kovinet commented 4 years ago

I also didn't have source maps by just running grunt watch, but if I first run grunt less:mytheme they appear.

I am not sure if map files are later updated on each change with grunt watch running ...

Eddcapone commented 4 years ago

Is there an update for this? I am using Magento 2.3.4 and style-m.css and styles-l.css are still showing in the browser.

Eddcapone commented 4 years ago

I finally figured it out. The sourcemaps where generated correctly, but in the wrong folder, since I configured my theme incorrectly in dev/tools/grunt/configs/local-themes.js:

Before:

module.exports = {
    company_base: {
        area: 'frontend',
        name: 'Company/Base',
        locale: 'de_DE',
        files: [
            'css/styles-m',
            'css/styles-l'
        ],
        dsl: 'less'
    },
};

After:

module.exports = {
    company_base: {
        area: 'frontend',
        name: 'company/base',       // <-- I had to change it to lower case
        locale: 'de_DE',
        files: [
            'css/styles-m',
            'css/styles-l'
        ],
        dsl: 'less'
    },
};

Open the file registration.php of your theme and check your path:

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

use \Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/company/base', __DIR__);

As you cans see I used company/base but in my local-theme.js I used Company/Base as name.

github-jira-sync-bot commented 3 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-1048 is successfully created for this GitHub issue.

m2-assistant[bot] commented 3 years ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

tuyennn commented 2 months ago

+1 for any update on this