FullHuman/purgecss-webpack-plugin

Error: No content provided.

john1jan opened this issue · 3 comments

I am using CleanWebpackPlugin which cleans my build folder from previous builds.

My build folder /build/client

output: {
    path: path.resolve('./build/client')
}

plugins:
new CleanWebpackPlugin('./build/client/'),
new PurgecssPlugin({
          paths: [...glob.sync(`${path.join(__dirname, './build/client/*')}/*`]
}),

The problem is PurgecssPlugin is trying to purgecss before webpack outputs the assets to build/client

Throws this error

build/client/* has been removed.
 92% recordingnode_modules/purgecss/lib/purgecss.js:1
(function (exports, require, module, __filename, __dirname) { "use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var fs=_interopDefault(require("fs")),glob=_interopDefault(require("glob")),postcss=_interopDefault(require("postcss")),selectorParser=_interopDefault(require("postcss-selector-parser"));function normalizeArray(e,t){for(var r=0,n=e.length-1;n>=0;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,splitPath=function(e){return splitPathRe.exec(e).slice(1)};function resolve(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return e=normalizeArray(filter(e.split("/"

Error: No content provided.
    at e.value (node_modules/purgecss/lib/purgecss.js:1:5408)
    at new e (node_modules/purgecss/lib/purgecss.js:1:4948)
    at node_modules/purgecss-webpack-plugin/lib/purgecss-webpack-plugin.js:203:44
    at Array.forEach (<anonymous>)

Hey, you should be adding the source files to the purgecss plugin.
if you look at the readme there is this example:

new PurgecssPlugin({
    paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true })
})

thanks its working fine now

@john1jan - how did you solve this? When I add { nodir: true } it gives me an "SyntaxError: Unexpected token {" error.

new CopyWebpackPlugin([ {from:'public/images',to:'images'} ]);

Is still gives me Error: No content provided. if I remove the dist folder.