Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: source map sources and file paths #753

Closed

Conversation

npetruzzelli
Copy link

What kind of change does this PR introduce?
half bugfix / half feature

Did you add tests for your changes?
Not yet, but they will be similar to existing tests. Waiting for feedback/comments.

If relevant, did you update the README?
Yes

Summary
The sources and file entries in sourcemaps are URLs relative to the file contains the source map (.css or .map) per version 3 of the source map specification.

For many loaders concerned with stylesheets, they currently try to treat them as file system paths, which has been a significant factor in errors that appear in these paths, especially when paths are being resolved without first checking if they are already absolute. These file system paths often end being relative to something other than the file containing the map.

"Under the hood" this loader uses PostCSS, which actually doesn't know about webpack's current request and remaining request. It only cares about file system paths. Part of the fix involves setting both the from (unmodified) and the to argument to being loader.resourcePath.

Using file system paths in maps is possible, but it is best left to the plugin responsible for writing the source map to the css file or the map file. The style-loader will have some additional considerations that are unique to it.

Once css-loader and sass-loader are fixed, postcss-loader and others will eventually need PRs as well.

Because the fix is a breaking change, but people may want to use it immediately (such as testing it with other loaders needing similar fixes), it has been implemented as a new option.

Does this PR introduce a breaking change?
No, but the intent is a future major version could make the opt-in fix the default behavior.

Other information
This contributes to the fixes for

…ult out of sensitivity to existing scripts that may expect this behavior.

Signed-off-by: Nick Petruzzelli <code.npetruzzelli@gmail.com>
@jsf-clabot
Copy link

jsf-clabot commented Aug 3, 2018

CLA assistant check
All committers have signed the CLA.

@npetruzzelli
Copy link
Author

See also: webpack-contrib/sass-loader#602

Signed-off-by: Nick Petruzzelli <code.npetruzzelli@gmail.com>
@codecov
Copy link

codecov bot commented Aug 3, 2018

Codecov Report

Merging #753 into master will increase coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #753      +/-   ##
==========================================
+ Coverage   99.45%   99.74%   +0.28%     
==========================================
  Files          10       10              
  Lines         370      388      +18     
  Branches      104       90      -14     
==========================================
+ Hits          368      387      +19     
+ Misses          2        1       -1
Impacted Files Coverage Δ
lib/loader.js 100% <100%> (ø)
src/utils.js
src/Warning.js
src/plugins/postcss-import-parser.js
src/cjs.js
src/plugins/postcss-icss-parser.js
src/CssSyntaxError.js
src/index.js
src/plugins/postcss-url-parser.js
src/runtime/api.js
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7525c9...625ffb1. Read the comment docs.

@npetruzzelli
Copy link
Author

Looks like the appveyor build is broken.

Build started
git clone -q https://github.com/webpack-contrib/css-loader.git C:\projects\css-loader
git fetch -q origin +refs/pull/753/merge:
git checkout -qf FETCH_HEAD

The build phase is set to "MSBuild" mode (default), but no Visual Studio project or solution files were found in the root directory. If you are not building Visual Studio project switch build mode to "Script" and provide your custom build command.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new option, please provide minimum reproducible test repo with bug, we should fix it without new option

Signed-off-by: Nick Petruzzelli <code.npetruzzelli@gmail.com>
@npetruzzelli
Copy link
Author

@evilebottnawi - I've removed the option part of it. I still need to update the test suite and create a test repo. It may take me some time to get to it. I'll comment again once it is all in place. You may see commits trickle in in the mean time.

pipeline.process(inputSource, {
from: postCssFrom,
from: options.from,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Break maps in many cases

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to the existing test suite? It is expected that it broke. I held off on updating the test suite as the comments in this review would determine how it would need to be updated.

The existing test suite is still using assumptions about source maps prior to the fix in this PR. I currently have the feedback I need and I intend to update the test suite prior to setting up the test repo.

If it isn't the test suite, is there a specific scenario you can describe that I can look into?

@michael-ciniawsky michael-ciniawsky changed the title Fix source map sources and file paths fix: source map sources and file paths Aug 7, 2018
@michael-ciniawsky michael-ciniawsky added this to the 1.0.1 milestone Aug 7, 2018
@michael-ciniawsky
Copy link
Member

First thx @npetruzzelli for the effort, but before we continue implementing we need to discuss the source map story as a whole. I had mutliple issue(s) about source maps since I'm maintaining these loaders and there were fixes provided that solved issues for some folks while adding new problems for others, it either is something which needs to be configurated for some cases or we just not getting it right atm... 😛

@npetruzzelli
Copy link
Author

@michael-ciniawsky - I am happy to discuss it. If I wanted a solution to work just for me I could publish a fork under a new namespace. My goal is to fix it for everyone. I see source maps as a valuable tool and these loaders will be the only option available to many who don't have the time/budget to learn how to make build systems from the ground up.

Can you share with me what the past issues were? The fix I'm envisioning sticks as close as possible to the source maps v3 spec. That said, if it breaks the tool for many users, then it isn't helping. If the use cases that need separate configuration can be clearly defined, I think it is a problem we can solve.

I am simply starting with css-loader and sass-loader. I can't speak for the JS source maps (yet), but I intend to touch more loaders and plugins related to the stylesheet source maps. The problem is not something you can point at one loader or plugin and say it is the source of the problem, at least with what I have found so far with css, sass, and postcss loaders. I'm not interested in pointing fingers, so I apologize if my choice of words seem harsh. I just want to help fix it!

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Aug 7, 2018

If I wanted a solution to work just for me I could publish a fork under a new namespace. My goal is to fix it for everyone.

I cause my comment sounds like if I implied your currently trying to do that, that's not the case

Can you share with me what the past issues were?

Sure, I will try to look some of them up, it was always about paths being incorrect (relative to the file in the wrong way etc) in a back and forth manner

  • mainly from Sass (sass-loader)
  • in conjunction with resolve-url-loader

The fix you propose in this PR already looks familiar to me (setting options.from/options.to to loader.resourcePath) and I think I used/tested it already and it worked to me knowledge, but it may break for some cases again, I haven't verify that part. I'm currently doing this in postcss-loader and not to long ago there was a PR which removed setting it for options.to, setting only the options.from value, but this broke resolve-url-loader :D

@npetruzzelli
Copy link
Author

npetruzzelli commented Aug 9, 2018

If I wanted a solution to work just for me I could publish a fork under a new namespace. My goal is to fix it for everyone.

I cause my comment sounds like if I implied your currently trying to do that, that's not the case

To clear things up, I didn't mean to make that implication! My PR effectively comes in and says that a past contributor got something wrong. My goal isn't to put that person down, I am here to help solve a challenge. I may have been overly self-conscious.

mainly from Sass (sass-loader) in conjunction with resolve-url-loader

I'm having difficulty figuring out what resolve-url-loader is supposed to do. Is it trying to transform instances of url() from being a path relative to the CSS file to a path that is relative to the document root? The resolve-url-loader also appears to be using file system paths (relative and absolute) instead of URLs. I'd have to understand the module developer's intent better before speculating further. In all cases, sass-loader would need to have its own part taken care of first. Early loaders need to be fixed before later loaders.

I hope to more time into the pull requests for css-loader and sass-loader either this weekend or early next week. This week has been really busy both in and out of work.

The fix you propose in this PR already looks familiar to me (setting options.from/options.to to loader.resourcePath) and I think I used/tested it already and it worked to me knowledge, but it may break for some cases again, I haven't verify that part

I took a quick look at postcss-loader and the related part of PostCSS's code. Even if this kind of trick works right now, there is no guarantee that it will work in the future as it is an undocumented implementation detail. PostCSS's own documentation is what says to set both values to the same path. At least for when I've used the Autoprefixer PostCSS plugin, I've always received expected source maps when providing both to and from values in this manner.

@ocoka
Copy link

ocoka commented Aug 10, 2018

Hello guys, I've just found this PR today, just before I create a new issue exactly about this ))
Here is the repo with a demo of such sourcemap bug
webpack-stylus-css-sourcemap-issue
with dir structure like this:
image
and index.js

import st from './assets/styles/main.styl';

I get this paths
'/home/ocoka/Documents/proj/test/src/assets/styles/ src/assets/styles/ buttons/buttons.styl',
'/home/ocoka/Documents/proj/test/src/assets/styles/main.styl'

double path bug

@ocoka
Copy link

ocoka commented Aug 10, 2018

Although ! maybe I don't understand that PR correctly and my problem related to behavior of stylus-loader ... just tested in my repo, and my problem still there

Signed-off-by: Nick Petruzzelli <code.npetruzzelli@gmail.com>
@npetruzzelli
Copy link
Author

Appveyor is failing in a way that I don't believe is related to the pull request.

TravisCI is failing because No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.. It looks like npm stalled for Node.js version 6 and it never had the opportunity to run the suite.

@evilebottnawi - I've updated the test suite. My next task is to setup a test repo. I plan to take another pass at the test suite after feedback. Do you have any specific criteria you would like to see in the test repo?

@michael-ciniawsky - Have I addressed the concerns for this repository? (not including updates other loaders or plugins, I intend to handle those within their respective repos). I'll be happy to continue the conversation!

lib/loader.js Outdated
* system. They don't know about, care about, or understand the webpack
* loader's current request or remaining request.
*/
processCssFrom = processFrom(this.resourcePath, map);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var from = getFrom(this.resourcePath, map)
var to = from

lib/loader.js Outdated
processCss(content, map, {
mode: moduleMode ? "local" : "global",
from: loaderUtils.getRemainingRequest(this).split("!").pop(),
to: loaderUtils.getCurrentRequest(this).split("!").pop(),
from: processCssFrom,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
  ...,
  // TODO use shorthand in next major
  from: from,
  to: to
}

lib/loader.js Outdated
*/
function processFrom(resourcePath, map) {
var effectiveResourcePath;
if (map && map.file && typeof map.file === 'string' && path.dirname(map.file) === '.') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.dirname(map.file) === '.' checks for a relative path here ? I'm not sure I'm following.. 😛 . In case my understanding is correct here, there is also path.isAbsolute(filepath) available

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done some thinking on it and here I may be trying to be too clever. What I originally was thinking of shouldn't be something that css-loader is responsible for. I can provide more details on what I was thinking if you'd like.

I'll try cleaning this up in my next commit.

		from: this.resourcePath,
		to: this.resourcePath,

will be enough.

lib/loader.js Outdated
if (map && map.file && typeof map.file === 'string' && path.dirname(map.file) === '.') {
// Something else has already changed the file name or extension, so
// honor it for the purpose of creating the next source map.
effectiveResourcePath = path.join(path.dirname(resourcePath), map.file);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide an example for effectiveResourcePath here :)

lib/loader.js Outdated
effectiveResourcePath = path.join(path.dirname(resourcePath), map.file);
} else {
effectiveResourcePath = resourcePath;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick 🐦 \n after the else block

lib/loader.js Outdated Show resolved Hide resolved
@npetruzzelli
Copy link
Author

@michael-ciniawsky - I'll try to have complete responses for you in the next day or so. Sorry for the delay!

@npetruzzelli
Copy link
Author

I'm in the process of merging in the most recent updates to:
https://github.com/webpack-contrib/css-loader/tree/master
into
https://github.com/npetruzzelli-forks/css-loader/tree/source-map-uris

I think I was able to carry over the bulk of my changes as a part of resolving the merge conflicts, but changes to unit testing means I have to update the test suite again. Once I update the test suite, I will be able to confirm whether or not this PR is still working as intended. I'm used to working with Mocha/Chai/Sinon. It may take a bit for me to wrap my head around Jest.

@alexander-akait
Copy link
Member

alexander-akait commented Nov 30, 2018

@npetruzzelli Great! If you have problems with jest, send a PR without tests, we can write this late 👍

@npetruzzelli
Copy link
Author

@evilebottnawi

I am still working on this, but found a couple things that are confusing me:

// lib/loader.js

   /* eslint-disable no-param-reassign */
   if (sourceMap) {
     if (map) {
       if (typeof map === 'string') {
         map = JSON.stringify(map);
       }

1. Why is no-param-reassign being disabled?

Isn't it generally considered a bad practice to reassign named arguments? Especially with V8 because it prevents code optimization by the engine/compiler? Does this only happen if the arguments object itself is accessed within the same function?

2. If the map is already a string, why are we stringifying it?

Valid types for PostCSS's prev property on the map option includes: String, Object, Boolean, and Function. It isn't stated, but I imagine undefined is valid, but I'm not sure about null.

See: https://github.com/postcss/postcss/blob/08cbd147c840e7ea54ea4a036acabd0673129e7a/docs/source-maps.md

@alexander-akait
Copy link
Member

Why is no-param-reassign being disabled?

We can refactor this logic. Also this place for buggy loaders.

If the map is already a string, why are we stringifying it?

Some loader pass string, some objects. Also just compatibility.

to: getCurrentRequest(this)
.split('!')
.pop(),
from: resourcePath,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is dangerous using this, also it is invalid use resourcePath, because it is not resource path, it is request, maybe you can create problem repository?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will take me a while to completely respond to this. If I am lucky, I can have something ready some time this week.

I need to understand more about the differences between when to use the request and when to use a file system path.


It is difficult to learn the details of the request syntax, because it does not exist on the website (https://webpack.js.org/concepts/) nor the documentation used to generate it (https://github.com/webpack/webpack.js.org). The closest we come is documentation on context: https://webpack.js.org/api/loaders/#the-loader-context.

There are some pages in the old wiki, but they don't go into a lot of detail and users looking for documentation might not expect to look in the deprecated docs repository wiki because they appear to have the same information at first glance and would expect the syntax to be documented on the site. In reality, the wiki contains information not present in the in the more up to date documentation: https://github.com/webpack/docs/wiki/loaders, https://github.com/webpack/docs/wiki/using-loaders.


The next post will probably be a big one.

Before I make it, I want to see if what I'm concerned about is still an issue or if I'm worried about nothing. My next step is to create the example repository that you requested as it will help illustrate what has been fixed and what still needs work. I can't rely only on the test suite just yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@npetruzzelli feel free to create minimum reproducible test repo, it is allow to me also identify the problem and how to fix it

Copy link
Author

@npetruzzelli npetruzzelli Dec 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @evilebottnawi,

I've created the repository that illustrates the problem. I'll need some time to get some text and images together to support/describe it clearly instead of needing you to dig through multiple pull requests and issues across multiple repositories for a clear picture.

https://github.com/npetruzzelli-forks/webpack-loader-demos/tree/dfffa81b02fd14fe7ece517b4048abfb0d33b761

I plan to use this repository to demonstrate the eventual solution just by pointing to a different Webpack file, probably in a new branch.

Relevant information:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@npetruzzelli great, thanks, i will see tomorrow, very tired today

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No rush! I know that feeling. Rest well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproducible test repo is not very simple, i try around 30 minutes to understand structure. Also looks many things broken, js source maps also doesn't work in you example. Please simplify example.

@npetruzzelli
Copy link
Author

The following is a diagram illustrating where in PostCSS that code relating to source maps may be found. I may be using it as a reference later on in this code review.

https://github.com/postcss/postcss/tree/046ab11f1be0eb3dd62bb3ea331134119168af11

PostCSS (lib/PostCSS.es6)
├── parse (same as PostCSS -> processor -> lazy-result)
└─┬ processor
  └─┬ lazy-result
    ├─┬ map-generator
    │ └── mozilla (is the source-map module)
    ├─┬ parse
    │ └─┬ input
    │   └─┬ previous-map
    │     └── mozilla (is the source-map module)
    └── result (this.map is an instance of `SourceMapGenerator` class from the `source-map` library, representing changes to the Result#root instance.)

@npetruzzelli
Copy link
Author

npetruzzelli commented Dec 3, 2018

Valid options.map.prev values

SUMMARY

  • PostCSS accepts a number of formats, but represents the maps internally as a stringified object.
  • Internally, Webpack expects loaders to expose source maps as plain objects
    • This seems to conflict with the documentation for this.callback which accepts any type that is acceptable to Mozilla's source-map module.
  • Niether PostCSS's nor Webpack's requirements and implementations are a hindrance to each other.

The details here are informational only. No action or response is being requested at this time. The details contain a TODO item to be looked at in the future.

DETAILS

I'm considering making the following recommendation:

  • For simplicity, the previous source map should be either stringified OR left unmodified when being supplied to PostCSS.

but I don't have enough information to make it worth someone else's effort to review it. The current state of the code would have no impact on the issues this PR attempts to solve.

The current code stringifies something that is already a string, but otherwise leaves the previous source map unmodified. This may or may not contribute to the issues in a subtle way. Currently, there are other items that need to be looked at before this.

PostCSS

prev string, object, boolean or function: source map content from a previous processing step (for example, Sass compilation). PostCSS will try to read the previous source map automatically (based on comments within the source CSS), but you can use this option to identify it manually. If desired, you can omit the previous map with prev: false.

Source: PostCSS and Source Maps documentation for options.

Publically, PostCSS accepts a number of possibilities:

  • The boolean literal false (true is not valid). This ignores previous source maps
  • A the source map object as a string
  • A function that is passed the options.map.from option as an argument. The returned result is expected to be a file system path that points to an existing map file. It uses Node's own fs module, so other file systems, such as memory-fs, are not supported.
  • An object that is an instance of SourceMapConsumer from Mozilla's source-map module.
  • An object that is an instance of SourceMapGenerator from Mozilla's source-map module.
  • A plain object that represents a source map.

Internally, PostCSS represents source maps as strings. Providing a string will avoid some condition checking and processing (source code).

Webpack

The first loader is passed one argument: the content of the resource file. The compiler expects a result from the last loader. The result should be a String or a Buffer (which is converted to a string), representing the JavaScript source code of the module. An optional SourceMap result (as JSON object) may also be passed.

Source: Loader API introduction.

  1. The first argument must be an Error or null
  2. The second argument a string or a Buffer.
  3. Optional: The third argument must be a source map that is parsable by this module.
  4. Optional: The fourth option, ignored by webpack, can be anything (e.g. some meta data).

Source: Loader API: this.callback

@npetruzzelli
Copy link
Author

npetruzzelli commented Dec 3, 2018

PostCSS's options.map.from And options.map.to Options

SUMMARY

  1. For the most dependable results, an absolute file system path should be passed as the value to this option.
  2. Since the css-loader is not responsible for writing the css files or source maps, the to value should be identical to the from value

The details here are informational. No review of the above recommendations are needed at this time as they may change once the reproducible test repository has been created and reviewed. The purpose of this post is to capture information and links that may be relevant to future discussion or decision making.

DETAILS

If options.map.from is not provided, PostCSS will attempt to determine the the file's location using the file property on the source map. This can lead to unexpected results as since it will silently fall back to the current working directory, which isn't necessarily going to be the correct location of the source file. (source: input Constructor, input.mapResolve).

If we provide options.map.from as a relative path, it is subject to a similarly unexpected result.

Both scenarios use Node.js's own path.resolve method is used to create an absolute file system path. It is this method that falls back to the current working directory to create an absolute file system path if the result of the function doesn't end up as one through the normal course of path resolution.

If after processing all given path segments an absolute path has not yet been generated, the current working directory is used.

The resulting path is normalized and trailing slashes are removed unless the path is resolved to the root directory.

Zero-length path segments are ignored.

Source: Node.js path.resolve([...paths])

To ensure that you generate an accurate source map, you must indicate the input and output CSS file paths — using the options from and to, respectively.

Source: PostCSS and Source Maps

2.1. Set from and to processing options
To ensure that PostCSS generates source maps and displays better syntax errors, runners must specify the from and to options. If your runner does not handle writing to disk (for example, a gulp transform), you should set both options to point to the same file:

processor.process({ from: file.path, to: file.path })

Source: PostCSS Runner Guidelines

The Webpack request syntax is not a valid argument for PostCSS's from and to options. Attempting to fix it and force it may work in some situations, but creates invalid source maps in others.

@alexander-akait
Copy link
Member

I know how postcss works (i am contributor of stylelint, prettier, cssnano and etc, which used postcss). Let's create repo with problem and i find solution how we should solve this problem

@npetruzzelli
Copy link
Author

@evilebottnawi : It looks like the master branch has been updated and the file structure has changed again. I'll need time to handle merge conflicts.


Here are some notes for the demonstration repository that I eventually plan to add to that repository's README:

NPM Scripts:

  • npm run build-all: Run all builds sequentially
  • npm run fullstack-build: Build a combination of Sass + PostCSS + CSS loaders, no fixes applied, to .tmp/dist/full-style-stack/
  • npm run fullstack-serve-dev: Serve a combination of Sass + PostCSS + CSS loaders, no fixes applied
  • npm run lint: Run ESLint
  • npm run postcss-build: Build a combination of PostCSS + CSS loaders, no fixes applied, to .tmp/dist/postcss-stack/
  • npm run postcss-serve-dev: Serve a combination of PostCSS + CSS loaders, no fixes applied
  • npm run sass-build: Build a combination of Sass + CSS loaders, no fixes applied, to .tmp/dist/sass-stack/
  • npm run sass-serve-dev: Serve a combination of Sass + CSS loaders, no fixes applied
  • npm run serve-src: Serve files from the source directories. Intended to be used in conjunction with Webpack's devServer.proxy option.
    • TODO: serve node_modules from this task as well.
  • npm run start: runs both fullstack-serve-dev and serve-src scripts.
  • npm run styles-build: Build a combination of CSS loaders, no fixes applied, to .tmp/dist/css-stack/
  • npm run styles-serve-dev: Serve a combination of CSS loaders, no fixes applied

Expected / Actual

When running the server and inspecting the paragraph of red lorem ipsum text, and examining the .my-lead-text rule in the developer console, the source line is not expected, accurate, or predicatable. Without an accurate and predicatable value, the proxy server can not be reasonably configured to serve source code files or files from node_modules for deeper inspection.

Note: the difference in port numbers are intentional.

  • EXPECTED:
    • ../../../../../../src/_assets/stylesheets/styles.scss, line 5 (Sass)
    • ../../../../../../src/_assets/stylesheets/styles.css, line 1 (CSS)
  • CSS + PostCSS + Sass: (actual)
    • http://localhost:9008/_assets/bundles/main/src/_assets/stylesheets/D:/Code/webpack-loader-demos/src/_assets/stylesheets/styles.scss, line 5
  • CSS + Sass: (actual)
    • http://localhost:9006/_assets/bundles/main/src/_assets/stylesheets/styles.scss, line 5
  • CSS + PostCSS: (actual)
    • http://localhost:9004/_assets/bundles/main/src/_assets/stylesheets/styles.css, line 1
  • CSS: (actual)
    • http://localhost:9002/_assets/bundles/main/styles.css, line 1

@npetruzzelli
Copy link
Author

npetruzzelli commented Dec 17, 2018

Please note that the demonstration repo does not yet include webpack configurations that demonstrate a fix.

https://github.com/npetruzzelli-forks/webpack-loader-demos/tree/dfffa81b02fd14fe7ece517b4048abfb0d33b761

@npetruzzelli
Copy link
Author

npetruzzelli commented Dec 17, 2018

For the sake of definition the .tmp ("temp" or "temporary") directory is a directory that will contain:

  • files that may be safely deleted at any time
  • built files that will never be put under version control, this may include
    • dist or "distribution" files: compiled bundles, scripts, styles, etc.
    • coverage files: code coverage reports generated from software tests
    • build related cache files, such as .sass-cache, if applicable

For the sake of definition the src (source) directory is a directory that will contain:

  • all files which may be considered an entry point (JavaScript or otherwise).
  • source code or files that needs to be processed or transformed
  • source code or files that this repository is responsible for maintaining

For the sake of definition the static directory (also known as the "public" directory) is directory that will contain:

  • files that this repository is responsible for maintaining, but don't need processing or transformation to be consumed. Examples of this includes a favicon, robots.txt, and humans.txt.
  • files that this repository is not responsible for maintaining, but still needs to consume. Examples of this includes third party libraries that can't be or won't be managed by software like bower, npm, or yarn. Third party files like this often end up in a sub-directory called "vendor" or similar.
  • When bundled, the only action taken on these files should be copying some or all of them from one location to another.

This directory is often considered to be a secondary source for an HTTP server's document root directory in development environments.


For the sake of definition the test directory is directory that will contain:

  • test suite related files, including spec files
    • some projects may have a convention defined that places unit test spec files in the same src directory as the code under test. In these cases the test directory may still contain other kinds of tests, including end-to-end/integration tests.

For the sake of definition the tools directory is directory that will contain:

  • configuration for development tools that don't need to be in the repository root directory
  • utilities for these development tools

Pretty much anything that helps you build and maintain your application, but isn't a part of the application itself would go here. In some cases, this may include additional application back end servers, API servers, or databases meant to support the front end in a development environment (if they are not a part of their own, separate code repository)

@npetruzzelli
Copy link
Author

@alexander-akait
Copy link
Member

@npetruzzelli thanks, we fix it in near future, many works right now, sorry for delay

@alexander-akait
Copy link
Member

/cc @npetruzzelli friendly ping, can we rebase?

@npetruzzelli
Copy link
Author

@evilebottnawi - I can try to set some time aside to rebase this branch and resolve any conflicts. I wasn't sure (based on the last comment in December) if you were working on a separate fix. I apologize for not seeking clarification.

Once I am caught up, I'll try to see if the demo repo can be updated/improved as well. Either way it shouldn't delay the rebase.

I'll try to tackle it at some point in the next few weeks. If I'm lucky, I may have time on Sunday to work on this.

@npetruzzelli
Copy link
Author

@evilebottnawi - I've begun working on updating this branch, but I've run into an error on commit:

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks commit -q -F C:\Users\UserName\AppData\Local\Temp\42ob4uyp.xi1
husky > pre-commit (node v8.9.4)
Stashing changes... [started]
Stashing changes... [skipped]
→ No partially staged files found...
Running linters... [started]
Running tasks for *.js [started]


eslint --fix [started]
eslint --fix [completed]
git add [started]
git add [completed]
Running tasks for *.js [completed]
Running linters... [completed]


Warning: Setting commit-msg script in package.json > scripts will be deprecated
Please move it to husky.hooks in package.json, a .huskyrc file, or a husky.config.js file
Or run ./node_modules/.bin/husky-upgrade for automatic update

See https://github.com/typicode/husky for usage

husky > commit-msg (node v8.9.4)






Using environment variable syntax ($GIT_PARAMS) in -e |--edit is deprecated. Use '{-E|--env} GIT_PARAMS instead'
D:\Code\css-loader\node_modules\@commitlint\cli\lib\cli.js:109
	throw err;
	^

Error: Received $GIT_PARAMS as value for -e | --edit, but GIT_PARAMS is not available globally.
    at getEditValue (D:\Code\css-loader\node_modules\@commitlint\cli\lib\cli.js:242:10)
    at normalizeFlags (D:\Code\css-loader\node_modules\@commitlint\cli\lib\cli.js:212:15)
    at D:\Code\css-loader\node_modules\@commitlint\cli\lib\cli.js:116:11
    at new Promise (<anonymous>)
    at main (D:\Code\css-loader\node_modules\@commitlint\cli\lib\cli.js:113:9)
    at Object.<anonymous> (D:\Code\css-loader\node_modules\@commitlint\cli\lib\cli.js:105:1)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)










husky > commit-msg hook failed (add --no-verify to bypass)
Completed with errors, see above.

I'll start investigating the error, but I was wondering if you might know how to resolve it. It is preventing me from committing.

@alexander-akait
Copy link
Member

@npetruzzelli remove node_modules and reinstall their

@npetruzzelli
Copy link
Author

@evilebottnawi - That was the first thing I tried. I tried it again just to be certain, but no luck.

I tried the following:

  • Deleting everything except for the .git directory and then discarded changes.
  • npm install

It appears to be working now, though it looks like there is a new commit message syntax that I'll have to follow, that is easy enough to do. I'll have a look at the CONTRIBUTING markdown.

I suspect the issue may have been in the generated dist directory. I should be able to resume work on this at the next available opportunity.

@alexander-akait
Copy link
Member

alexander-akait commented Feb 21, 2019

The main goal of this PR it testing source maps on windows/maos/linux with/without postcss-loader, we can avoid sass-loader testing here (it is part of sass-loader tests)

@alexander-akait
Copy link
Member

Looks we need do this manually and add tests step by step

@alexander-akait
Copy link
Member

Done in #901, will be released in near future, feel free to tests and if you faced with issue feel free to create new issue with reproducible test repo, thanks for PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants