Skip to content

Global styles and scripts are not injected if project path includes a junction #2726

Closed
@tallaxes

Description

@tallaxes

OS?

Windows 10

Versions.

angular-cli: 1.0.0-beta.17
node: 6.6.0
os: win32 x64

Repro steps.

mkdir scratch
cd scratch
ng new proj
cd ..
mklink /j scratch-link scratch    # creates a junction
cd scratch\proj
ng build

The log given by the failure.

The global styles (src\styles.css) won't be injected, the resulting dist\styles.bundle.js won't have any trace of style-loader. I think the same thing will happen with global scripts, but I focused on styles.

Mention any other details that might be useful.

(Junction is one flavor of symbolic link on Windows; have not tested with other kinds. I would not be surprised if the same thing happens with symbolic or hard links on Linux, but I have not tested.)

The problem is related to the webpack configuration, specifically the include check for the global files that need to be included for style-loader/script-loader processing. The file names used to build the configuration (styles and scripts arrays) are derived from the project location and don't reflect anything about the junction. The resource names passed in by webpack for matching at runtime, however, are normalized (presumably with something like fs.realpath) and point to the original location of the files. Consequently, file names that should be selected for special processing are not matched.

It is possible that it is webpack that should process file names in the configuration in the same way it normalizes the names of the resources passed in. Or, at the CLI level, file names in the config could be normalized with fs.realpathSync. Or one can just avoid using links.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenttype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions