webpack-contrib / purifycss-webpack

UNMAINTAINED, use https://github.com/FullHuman/purgecss-webpack-plugin
MIT License
772 stars 37 forks source link

data.paths['templates'] should NOT have additional properties #92

Closed IAMtheIAM closed 7 years ago

IAMtheIAM commented 7 years ago

I'm getting this error: data.paths['templates'] should NOT have additional properties at Object.apply

This is my config object for paths:

   paths: {
            templates: glob.sync(path.join(helpers.paths.root, "/src/app-components/**/*.template.html")),
            components: glob.sync(path.join(helpers.paths.root, "/src/app-components/**/*.component.ts")),
         },

I logged the globs as I have them and they output an array of absolute paths. What am I doing wrong here?

bebraw commented 7 years ago

Hi,

The check is fairly strict. It generates the validation based on your configuration entries. The error says there's something extra. It would be cool to make it tell which ones.

IAMtheIAM commented 7 years ago

I replaced my glob with an actual array of absolute paths (the one I got back from glob), and it still gives the same error message. Even if I shorten it to only 1 path like this, same error:

         paths: {
            templates: ['C:/Source/MyProject/src/app-components/detail.template.html']
        },

I don't see anything extra on it.

bebraw commented 7 years ago

Hi,

Do you have an entry named templates? Can you paste your entry configuration?

The exact check is here.

IAMtheIAM commented 7 years ago

Hi. Maybe I misunderstood how to use the object. Really what I'm trying to do is this. From the old API in purifycss-webpack-plugin, I had:

         basePath: helpers.paths.root,
         paths: [
            "/src/app-components/**/*.template.html",
            "/src/app-components/**/*.component.ts",
         ],

So now that I'm trying to upgrade to the new api, I just want to get all the files in those two path globs. I thought I could make up any entry name but I guess not. How could I accomplish this?

bebraw commented 7 years ago

If you don't want to constrain it per entry, you can pass an array of absolute paths to paths.

IAMtheIAM commented 7 years ago

Thanks, I figured it out. I had to create a glob of each path, then concat them together into 1 array.

// top of file
const templatesPath = helpers.glob.sync(helpers.path.join(helpers.paths.root, "/src/app-components/**/*.template.html"));
const componentsPath =  helpers.glob.sync(helpers.path.join(helpers.paths.root, "/src/app-components/**/*.component.ts"));

// plugins
  new PurifyCSSPlugin({
     paths: templatesPath.concat(componentsPath),
}

It would be nice if we could just path in two globs like we could in the old API. It would keep the code a little neater.

bebraw commented 7 years ago

I could accept a PR for that. I decoupled glob from the API on purpose but it could be made optional (easier to consume).