我在使用wp4时遇到麻烦,昨天我做了一些构建,但是现在删除dist文件夹后,它开始通过使用缓存或内存服务而不是创建文件来解决此问题
我的应用程序结构为: - 根文件夹 - 上市 -src 在这里配置
我的webpack配置:
//const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require('path')
console.log("Bundling the application..")
module.exports = {
watch: true,
target: 'web',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
publicPath: '',
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
presets: ['react', 'es2015', 'env'],
plugins: ['transform-class-properties']
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
loader: 'css-loader',
options: {
modules: true,
minimize: true
}
})
},
/*{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
// you can specify a publicPath here
// by default it use publicPath in webpackOptions.output
publicPath: '',
modules: true
}
},
"css-loader"
]
},*/
{
test: /\.(woff(2)?|ttf|png|jpg|gif|svg)$/,
loader: 'file-loader',
/*loader: "file-loader?name=/img/[name].[ext]", */
query: {
name: '[name].[ext]?[hash]'
}
}
]
},
plugins: [
new ExtractTextPlugin({
filename: 'web.css',
disable: false,
allChunks: true
}),
/*new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
}),*/
new HtmlWebpackPlugin({
title: "Track on Performance",
template: "./public/index.html",
filename: "index.html"
})
],
resolve: {
extensions: ['.js', '.json', '.jsx']
},
devServer: {
port: 3000,
watchContentBase: true,
compress: true
}
};
我在控制台上没有错误,因为您也可以尝试使用迷你css提取程序,但问题仍然存在