spatie / laravel-mix-purgecss

Zero-config Purgecss for Laravel Mix
https://spatie.be/en/opensource
MIT License
874 stars 38 forks source link

Error on `extractor` #63

Closed Firesphere closed 5 years ago

Firesphere commented 5 years ago

I keep getting this error, and I'm unsure where I'm doing things wrong:

PurgeCSSTypeError: Cannot read property 'extractor' of undefined                                                                                                                                                                                              at Purgecss.getFileExtractor (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\purgecss\lib\purgecss.js:700:33)                                                                                                                                                             at Purgecss.extractFileSelector (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\purgecss\lib\purgecss.js:646:50)                                                                                                                                                          at Purgecss.purge (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\purgecss\lib\purgecss.js:409:41)                                                                                                                                                                        at C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:282:33                                                                                                                                                           at Array.forEach ()                                                                                                                                                                                                                                                             at C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:247:23                                                                                                                                                           at Array.forEach ()                                                                                                                                                                                                                                                             at PurgecssPlugin.runPluginHook (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:235:26)                                                                                                                            at C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\purgecss-webpack-plugin\lib\purgecss-webpack-plugin.js:219:18                                                                                                                                                           at _err0 (eval at create (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\tapable\lib\HookCodeFactory.js:32:10), :21:1)                                                                                                                                         at compilation.hooks.additionalAssets.tapAsync.assetCb (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:330:9)                                                                                          at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\tapable\lib\HookCodeFactory.js:32:10), :12:1)                                                                                                           at AsyncSeriesHook.lazyCompileHook (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\tapable\lib\Hook.js:154:20)                                                                                                                                                            at hooks.optimizeTree.callAsync.err (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\webpack\lib\Compilation.js:1307:32)                                                                                                                                                   at _err0 (eval at create (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\tapable\lib\HookCodeFactory.js:32:10), :16:1)                                                                                                                                         at _async2.default.forEach.err (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:296:11)                                                                                                                 at C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\async\dist\async.js:473:16                                                                                                                                                                                              at iteratorCallback (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\async\dist\async.js:1064:13)                                                                                                                                                                          at C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\async\dist\async.js:969:16                                                                                                                                                                                              at _async2.default.forEach.err (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:274:13)                                                                                                                 at C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\async\dist\async.js:473:16                                                                                                                                                                                              at iteratorCallback (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\async\dist\async.js:1064:13)                                                                                                                                                                          at C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\async\dist\async.js:969:16                                                                                                                                                                                              at compilation.rebuildModule.err (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\laravel-mix\node_modules\extract-text-webpack-plugin\dist\index.js:261:26)                                                                                                               at callback (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\webpack\lib\Compilation.js:1133:5)                                                                                                                                                                            at processModuleDependencies.err (C:\Users\simon\projects\haveibeenpwnd\themes\watea\node_modules\webpack\lib\Compilation.js:1156:5)                                                                                                                                                       at _combinedTickCallback (internal/process/next_tick.js:131:7)                                                                                                                                                                                                                             at process._tickCallback (internal/process/next_tick.js:180:9)                                                                                                                                                                                                                         Done in 70.36s.
--

My webpack.mix.js:

let mix = require('laravel-mix');
let path = require('path');
let glob = require('glob-all');
require('laravel-mix-purgecss');

//this fixes an API change introduced at //https://github.com/webpack/webpack/issues/4549
mix.setPublicPath(
  path.join(__dirname, 'dist')
);
mix.setResourceRoot('../');
mix.sass('src/scss/main.scss', 'css/main.css').purgeCss({
  enabled: true,

  // Your custom globs are merged with the default globs. If you need to
  // fully replace the globs, use the underlying `paths` option instead.
  paths: () => glob.sync([
    path.join(__dirname, 'templates/**/**/**/*.ss'),
    path.join(__dirname, 'templates/**/**/*.ss'),
    path.join(__dirname, 'templates/**/*.ss'),
    path.join(__dirname, 'templates/*.ss')
  ])
});
mix.js('src/js/main.js', 'js/main.js');
mix.js('src/js/chart.js', 'js/chart.js');

mix.webpackConfig({
  externals: {
    jquery: 'jQuery'
  }
});
Firesphere commented 5 years ago

I don't know what I did, but this issue has resolved itself.