You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 23, 2018. It is now read-only.
I recently incorporated webpack-cleanup-plugin into a Webpack project I've recently started.
The important part of my Webpack configuration, that which is related to the issue I am having, is shown below:
{output: {// Root directory for all build artifacts.path: path.join(process.cwd(),`dist/`),}}
The value for path contains a trailing slash.
The resulting value of fromPath in getFiles would be C:\Users\hbetts\Workspace\application\dist\, with C:\Users\hbetts\Workspace\application\ being the directory of my Webpack-managed project.
The function that maps files located at that path, correctly returns files like - C:\Users\hbetts\Workspace\application\dist\application.js
I would expect webpack-cleanup-plugin to delete application.js.
What happens, though, is on the p.substr(npath.length + 1) line the length of my normalized fromPath, which is 43 characters, including the trailing slash, is incremented by 1, and then a substring of the full file path is taken, effectively removing the first 44 characters, which happens to be the last slash, plus that one extra character, the letter a.
Therefore I'm left with a substring of pplication.js.
Later, when the normalized fromPath is joined with the file name (the value of the substring operation), I get C:\Users\hbetts\Workspace\application\dist\pplication.js
An alternative approach would be to replace:
p.substr(npath.length+1)
With:
require('path').basename(p)
basename returns the expected file name application.js.
I recently incorporated
webpack-cleanup-plugin
into a Webpack project I've recently started.The important part of my Webpack configuration, that which is related to the issue I am having, is shown below:
The value for
path
contains a trailing slash.The resulting value of
fromPath
ingetFiles
would beC:\Users\hbetts\Workspace\application\dist\
, withC:\Users\hbetts\Workspace\application\
being the directory of my Webpack-managed project.The function that maps files located at that path, correctly returns files like -
C:\Users\hbetts\Workspace\application\dist\application.js
I would expect
webpack-cleanup-plugin
to deleteapplication.js
.What happens, though, is on the
p.substr(npath.length + 1)
line the length of my normalizedfromPath
, which is 43 characters, including the trailing slash, is incremented by 1, and then a substring of the full file path is taken, effectively removing the first 44 characters, which happens to be the last slash, plus that one extra character, the lettera
.Therefore I'm left with a substring of
pplication.js
.Later, when the normalized
fromPath
is joined with the file name (the value of the substring operation), I getC:\Users\hbetts\Workspace\application\dist\pplication.js
An alternative approach would be to replace:
With:
basename
returns the expected file nameapplication.js
.cc @foxbunny
Also #23 may actually resolve this issue. I just haven't tried it yet.
The text was updated successfully, but these errors were encountered: