i 「wdm」: Compiled with warnings.
i 「wdm」: Compiling...
D:\gitproject\WebServer\node_modules\_html-webpack-plugin@3.2.0@html-webpack-plugin\lib\compiler.js:111
content: childCompilation.assets[outputName].source()
^
TypeError: Cannot read property 'source' of undefined
at childCompiler.runAsChild (D:\gitproject\WebServer\node_modules\_html-webpack-plugin@3.2.0@html-webpack-plugin\lib\compiler.js:111:56)
at compile (D:\gitproject\WebServer\node_modules\_webpack@4.6.0@webpack\lib\Compiler.js:242:11)
at hooks.afterCompile.callAsync.err (D:\gitproject\WebServer\node_modules\_webpack@4.6.0@webpack\lib\Compiler.js:487:14)
at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\gitproject\WebServer\node_modules\_tapable@1.0.0@tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (D:\gitproject\WebServer\node_modules\_tapable@1.0.0@tapable\lib\Hook.js:35:21)
at compilation.seal.err (D:\gitproject\WebServer\node_modules\_webpack@4.6.0@webpack\lib\Compiler.js:484:30)
at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\gitproject\WebServer\node_modules\_tapable@1.0.0@tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (D:\gitproject\WebServer\node_modules\_tapable@1.0.0@tapable\lib\Hook.js:35:21)
at hooks.optimizeAssets.callAsync.err (D:\gitproject\WebServer\node_modules\_webpack@4.6.0@webpack\lib\Compilation.js:966:35)
at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\gitproject\WebServer\node_modules\_tapable@1.0.0@tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (D:\gitproject\WebServer\node_modules\_tapable@1.0.0@tapable\lib\Hook.js:35:21)
at hooks.optimizeChunkAssets.callAsync.err (D:\gitproject\WebServer\node_modules\_webpack@4.6.0@webpack\lib\Compilation.js:957:32)
at _err0 (eval at create (D:\gitproject\WebServer\node_modules\_tapable@1.0.0@tapable\lib\HookCodeFactory.js:24:12), <anonymous>:11:1)
at D:\gitproject\WebServer\node_modules\_uglifyjs-webpack-plugin@1.2.5@uglifyjs-webpack-plugin\dist\index.js:334:11
at _class.runTasks (D:\gitproject\WebServer\node_modules\_uglifyjs-webpack-plugin@1.2.5@uglifyjs-webpack-plugin\dist\uglify\index.js:63:9)
at UglifyJsPlugin.optimizeFn (D:\gitproject\WebServer\node_modules\_uglifyjs-webpack-plugin@1.2.5@uglifyjs-webpack-plugin\dist\index.js:253:16)
D:\gitproject\WebServer>webpack-dev-server
用webpack4时候出了的问题
wasd258096
#1
wasd258096
#4
另外 贴一下 配置文件
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
/*var ExtractTextPlugin = require("extract-text-webpack-plugin");*/
var rootPath = __dirname + '/';
var config = {
src:rootPath + 'src',
dist:rootPath + 'public',
}
/*var extractLess = new ExtractTextPlugin({
filename: "css/[name].[contenthash:8].css",
});
*/
var config = {
devtool: 'false',
context: path.resolve(__dirname, './src'),
entry: {
'vendor': [
'react',
'react-redux',
'react-dom',
'redux',
'react-router-dom',
'redux-thunk'
],
app: config.src +'/index.js'
},
output: {
path:config.dist,
publicPath: '/',
filename: 'js/[name].js',
chunkFilename: "js/[name].js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use:[{loader:"babel-loader"}]
},
{
test: /\.css/,
use: [
{
loader: "style-loader"
}, {
loader: "css-loader",
options: {
modules: true, // 指定启用css modules
localIdentName: '[name]_[local]_[hash:base64:5]' // 指定css的类名格式
}
}
]
},
{
test: /\.less$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "less-loader"
}]
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader',
options: {
limit: 8129
}
}
]
},
devServer:{
historyApiFallback: true,
hot: true, //HMR模式
inline: true,//实时刷新
port: 8181, // 修改端口,一般默认是8080
contentBase:__dirname+"/src"
},
resolve: {
extensions: ['.js', '.jsx', '.css'],
modules: [path.resolve(__dirname, './src'), 'node_modules']
},
optimization: {
runtimeChunk: {
name: "manifest"
},
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
priority: -20,
chunks: "all"
}
}
}
},
plugins:[
new HtmlWebpackPlugin({
template:__dirname+"/src/index.html",
filename:__dirname+"/public/index.html"
}),
new webpack.HotModuleReplacementPlugin({
multiStep:true,
})
]
}
module.exports = config;