Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript PurifyCss插件是否可以强制等待捆绑包准备就绪?_Javascript_Css_Webpack_Purifycss - Fatal编程技术网

Javascript PurifyCss插件是否可以强制等待捆绑包准备就绪?

Javascript PurifyCss插件是否可以强制等待捆绑包准备就绪?,javascript,css,webpack,purifycss,Javascript,Css,Webpack,Purifycss,在我开始集成之前,我的第一个“Hello Webpack”项目进展顺利。如果我手动删除我的/dist文件夹,然后生成,则此配置有效。但是,如果/dist文件夹存在并按其设计方式将其删除,PurifyCSS将抛出以下错误: 清除网页包插件:\dist已被删除。 purifycss网页包\dist\index.js:52\if(!\u fs2.default.existsSync(p)) 抛出新错误('路径'+p+'不存在') 有没有其他方法可以让Webpack仅在所有其他插件执行后才运行Purif

在我开始集成之前,我的第一个“Hello Webpack”项目进展顺利。如果我手动删除我的/dist文件夹,然后生成,则此配置有效。但是,如果/dist文件夹存在并按其设计方式将其删除,PurifyCSS将抛出以下错误:

清除网页包插件:\dist已被删除。
purifycss网页包\dist\index.js:52\if(!\u fs2.default.existsSync(p)) 抛出新错误('路径'+p+'不存在')

有没有其他方法可以让Webpack仅在所有其他插件执行后才运行PurifyCSS?我以为我是通过把它放在插件数组的最后一个来实现的,但这对我来说就像是执行顺序的问题。这是我的配置:

const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const globAll = require('glob-all');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const PurifyCSSPlugin = require('purifycss-webpack');
const webpack = require("webpack");

var extractPluginCSS = new ExtractTextPlugin({
  filename: "app.css"
});

module.exports = {
  entry: "./src/js/app.js",

  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "app.js"
  },

  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: [
          {
            loader: "babel-loader",
            options: {
              presets: ["env"]
            }
          }
        ]
      },

      {
        test: /app\.scss$/,
        use: extractPluginCSS.extract({
          use: [
            {
              loader: "css-loader",
              options: {}
            },
            {
              loader: "sass-loader",
              options: {}
            }
          ]
        })
      },

      {
        test: /\.html$/,
        use: ["html-loader"]
      },

      {
        test: /\.(jpg|png)$/,
        use: [
          {
            loader: "file-loader",
            options: {
              name: "[name].[ext]",
              outputPath: "img/"
            }
          }
        ]
      }

    ]
  },

  plugins: [

    new CleanWebpackPlugin(['dist']),

    new HtmlWebpackPlugin({
      template: "./src/html/index.html"
    }),

    new webpack.optimize.UglifyJsPlugin(),

    extractPluginCSS,

    new PurifyCSSPlugin({
      // Give paths to parse for rules. These should be absolute!
      paths: globAll.sync([
        path.join(__dirname, '/dist/*.html')
      ]),
      // minimize: true,
      verbose: true
    })

  ]

};