Closed beckend closed 7 years ago
@beckend Hi, the GitHub readme represents the next version. You have to look up the instructions from npm. I'm still waiting a reply from npm as I need release rights and @IngwiePhoenix isn't being responsive either.
@beckend The new version is out. Please give that a go.
Get different error using exact same thing in my first comment:
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.extname (path.js:1431:5)
at /Users/linken/project/node_modules/purifycss-webpack/dist/search.js:26:36
at Array.map (native)
at Object.searchFiles [as files] (/Users/linken/project/node_modules/purifycss-webpack/dist/se
arch.js:23:31)
at /Users/linken/project/node_modules/purifycss-webpack/dist/index.js:53:77
at Array.forEach (native)
at /Users/linken/project/node_modules/purifycss-webpack/dist/index.js:49:28
at Array.forEach (native)
at Compilation.<anonymous> (/Users/linken/project/node_modules/purifycss-webpack/dist/index.js
:34:30)
at next (/Users/linken/project/node_modules/tapable/lib/Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (/Users/linken/project/node_modules/extract-text-webpack-plug
in/index.js:316:4)
at Compilation.applyPluginsAsyncSeries (/Users/linken/project/node_modules/tapable/lib/Tapable
.js:142:13)
at sealPart2 (/Users/linken/project/node_modules/webpack/lib/Compilation.js:597:9)
at next (/Users/linken/project/node_modules/tapable/lib/Tapable.js:138:11)
at Compilation.<anonymous> (/Users/linken/project/node_modules/webpack/lib/ProgressPlugin.js:1
10:5)
at next (/Users/linken/project/node_modules/tapable/lib/Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (/Users/linken/project/node_modules/extract-text-webpack-plug
in/index.js:292:5)
at /Users/linken/project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/asyn
c.js:356:16
at iteratorCallback (/Users/linken/project/node_modules/extract-text-webpack-plugin/node_modul
es/async/dist/async.js:936:13)
at /Users/linken/project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/asyn
c.js:840:16
at /Users/linken/project/node_modules/extract-text-webpack-plugin/index.js:276:6
at /Users/linken/project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/asyn
c.js:356:16
at iteratorCallback (/Users/linken/project/node_modules/extract-text-webpack-plugin/node_modul
es/async/dist/async.js:936:13)
at /Users/linken/project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/asyn
c.js:840:16
at /Users/linken/project/node_modules/extract-text-webpack-plugin/index.js:273:13
at /Users/linken/project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/asyn
c.js:3025:16
at eachOfArrayLike (/Users/linken/project/node_modules/extract-text-webpack-plugin/node_module
s/async/dist/async.js:941:9)
at eachOf (/Users/linken/project/node_modules/extract-text-webpack-plugin/node_modules/async/d
ist/async.js:991:5)
at Object.eachLimit (/Users/linken/project/node_modules/extract-text-webpack-plugin/node_modul
es/async/dist/async.js:3089:3)
@beckend Can you set up a small GitHub repository showing the error? That will allow me to patch it the right way. Some little assumption is wrong in the code.
Will do in the weekend when i'm off, the current plugin was tested on a huge project.
Ok, cool.
I added stricter validation yesterday so that should catch possible configuration related problems.
I found this in the schema:
paths: {
type: ['array', 'object'],
items: {
type: 'string'
}
},
Are you saying the item property in the object can only be string? I mean it's going to be an array of strings in my case.
these are the options I logged in the plugin before validation:
{
"extensions": [
".html",
".pug"
],
"paths": {
"desktop": "dasdas",
"mobile": "dsadas"
},
"purifyOptions": {
"info": true,
"minify": true,
"rejected": false
}
}
Then it fails with:
throw new Error(validation.error);
^
Error: data should NOT have additional properties
With the above and reading the schema, it passes validation if I change "extensions" to "fileExtensions" since you updated the plugin.
Ok. Check out the fileExtensions
and moduleExtensions
properties. extensions
was removed as it was unclear.
Yup. The split was on purpose. I can change the naming as fileExtensions
feels too vague.
Ok I tried to replicate on a smal repo, wasn't successful.
So I temp open my repo which is a skeleton boilerplate at https://bitbucket.org/linken/webpack-boiler-ts
branch is purify-css-1
Instructions to get it running:
npm -g i yarn gulp-cli
yarn
- to install depsNODE_ENV='production' gulp clean:build build:web
And I get some really weird error.Please let me know if you decide to clone it, so I can close it later.
webpack configs are in internals/webpack
@beckend Hi, I got it running. After I hit build as instructed, it gets stuck on 92% chunk asset optimization
while taking all my CPU (new quad core). Is that to be expected? Note that I'm running Node 6, not 7.
What kind of error are you getting? Can you simplify the project somehow while still retaining it?
Nm. The error is above (TypeError: Path must be a string. Received undefined
). Still, it would be fun to get this running so I can debug and fix. Most likely it's missing some check against webpack in some very specific case. š
I could likely fix this blind (extra filter
), but I'll wait for a simplified project so it's easier to see what's really going on.
You can likely simplify
fileExtensions: [
'.css',
'.html',
'.less',
'.pug',
'.sass',
'.scss',
'.styl',
],
to include only styling files (so just css
, sass
etc.). That might help a notch. I actually renamed that field to styleExtensions
to communicate the meaning better.
When I debugged last time, I hit this line which yields undefined, thus the error you saw. https://github.com/webpack-contrib/purifycss-webpack/blob/master/src/search.js#L18
Yup. It's that path.extname(file)
. What if we added a check against file
and bailed if it's not there? I think I'll add just that.
I included the check in 0.3.1
as it definitely doesn't hurt. Feel free to close this issue once you can verify this has fixed the problem.
Progress, it now hits the next thing: https://github.com/webpack-contrib/purifycss-webpack/blob/master/src/index.js#L41
TypeError: (paths[chunkName] || paths).concat is not a function
Basically it's the same problem as the search one, where paths[chunkName]
is undefined.
@beckend I see the problem. Your uglify config has desktop
, but your entries are named like entry-desktop
. Because of that mismatch, it crashes right there.
I think I'll add extra validation against that case so it's possible to detect early on.
I think you hit the nail with that! This should also mean that the search function thing you worked on should be reverted, and should throw an error there instead. It now works.
The search check is fine. It doesn't hurt to avoid runtime errors. š
I'll close this issue after I have that other check in place.
Alright thanks, I have another issue where the purified build does not look like the unpurified build. Will open another thread when I'm done with my confirmation. I'll leave this one for you.
Error: