webpack-dev-server 老是卡住!!为何?
我的配置文件:
webpack.common.js
:
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// 编译后文件输出路径
const outputDir = 'compiled';
module.exports = {
// 入口
entry: {
// 单一入口
app_v1: ['babel-polyfill' , './source/app.js']
} ,
plugins: [
new CleanWebpackPlugin([outputDir]),
new HtmlWebpackPlugin({
filename: 'app.html' ,
template: 'template.html'
}) ,
new VueLoaderPlugin() ,
new MiniCssExtractPlugin({
filename: "[name].css" ,
chunkFilename: "[id].css"
}) ,
] ,
output: {
filename: 'js/[name].js' ,
path: path.resolve(__dirname , outputDir)
} ,
module: {
rules: [
{
test: /\.js/ ,
// 如果不排除 node_modules,babel 编译速度将会非常慢
exclude: /node_modules/ ,
use: {
loader: 'babel-loader' ,
options: {
"presets": ["@babel/preset-env"] ,
plugins: [
// 提升运行速度 详情请查看 https://webpack.js.org/loaders/babel-loader/#root
'@babel/plugin-transform-runtime' ,
// 支持动态导入语法
'@babel/plugin-syntax-dynamic-import' ,
]
}
}
} ,
{
test: /\.css/ ,
use: [
MiniCssExtractPlugin.loader ,
// 'vue-style-loader' ,
{
loader: 'css-loader' ,
options: {
sourceMap: true
}
}
]
} ,
{
test: /\.(png|svg|jpg|gif)$/ ,
use: [
{
loader: 'file-loader' ,
options: {
name: 'assets/image/[name].[ext]'
}
}
]
} ,
{
test: /\.vue$/ ,
loader: 'vue-loader'
} ,
{
test: /\.(woff|woff2|eot|ttf|otf)$/ ,
use: [
{
loader: 'file-loader' ,
options: {
name: '[name].[ext]'
}
}
],
}
]
} ,
resolve: {
alias: {
}
}
};
webpack.dev.js
:
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common , {
mode: 'development' ,
devtool: 'inline-source-map' ,
devServer: {
contentBase: path.resolve('../../') ,
index: 'app.html' ,
host: '127.0.0.1' ,
port: 9000 ,
}
});
运行一段时间就卡住,然后 ctrl + c
终止,再必须再任务管理器中结束 nodejs
进程,否则无法再运行!
非常频繁,太频繁了!为啥会出现这种情况?webpack-dev-server
如此不稳定吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论