want to add purifycss function, but after build, a lot of useful css have not been packaged?
webpack.build.js
var webpack = require("webpack");
var path = require("path");
var glob = require("glob");
let HtmlWebpackPlugin = require("html-webpack-plugin");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const PurifyCSSPlugin = require("purifycss-webpack");
//
var ROOT_PATH = path.resolve(__dirname);
var SRC_PATH = path.resolve(ROOT_PATH, "src");
var BUILD_PATH = path.resolve(ROOT_PATH, "dist");
var NODE_MODULES_PATH = path.resolve(ROOT_PATH, "node_modules");
console.log(1121212)
console.log(glob.sync(path.join(SRC_PATH, "/*.html")))
module.exports = {
entry: {
app: path.resolve(__dirname, "src/app.js")
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
publicPath: "/",
chunkFilename: "[name].js"
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader"]
})
},
{
test: /\.scss$/,
// loader: "style-loader!css-loader!sass-loader!postcss-loader"
use: ExtractTextPlugin.extract({
fallback: "style-loader",
// resolve-url-loader may be chained before sass-loader if necessary
use: ["css-loader?minimize", "postcss-loader", "sass-loader"]
})
},
{
test: /\.less$/,
use: [
{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "less-loader"
},
]
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.(png|jpg|gif|svg)/,
use: [
{
loader: "url-loader",
options: {
limit: 8192,
name: "imgs/[name].[hash:4].[ext]"
}
}
]
},
{
test: /\.(htm|html)/,
use: ["html-withimg-loader"]
},
]
},
resolve: {
extensions: [".js", ".jsx", ".json", "jsonp", ".scss", ".less"]
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: ""production"",
},
}),
//
new CleanWebpackPlugin(BUILD_PATH),
//
new CopyWebpackPlugin([
{
from: __dirname + "/src/components",
to: __dirname + "/dist/components",
ignore: "*.jsx"
}
]),
//
// new FriendlyErrorsPlugin(),
//
// new webpack.NoEmitOnErrorsPlugin(),
// CSS
new ExtractTextPlugin("css/style.css"),
// css
new PurifyCSSPlugin({
paths: glob.sync(path.join(SRC_PATH, "/index.html"))
})
],
devServer: {
// contentBase: SRC_PATH,
inline: true,
port: 7000
},
devtool: "source-map"
};