/**
* Created by Administrator on 2020/5/28.
*/
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
//const UglifyjsWebpackPlugin = require('uglifyjs-webpack-plugin')
const path = require('path')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname,'dist'),
publicPath: '../dist/',
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.css$/,
use: [
//cssloader负责将css进行加载
//styleloader负责将样式添加到dom中
//使用多个Loader的时候是从右向左的顺序
{ loader: 'style-loader'},
{ loader: 'css-loader'},
]
},
{
test: /\.less$/,
use: [
{ loader: 'style-loader'},
{ loader: 'css-loader'},
{ loader: 'less-loader'}
]
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 99999999,
name: 'img/[name].[hash:8].[ext]'
},
}
]
},
{ test: /\.vue$/,
use: ['vue-loader']
}
]
},
resolve: {
//别名
extensions: ['.js','.vue'],
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
plugins: [
new webpack.BannerPlugin('mr.Z制造'),
new HtmlWebpackPlugin({
template: 'index.html'
}),
/*new UglifyjsWebpackPlugin()*/
],
devServer: {
contentBase:'./dist',
inline: true //是否实时进行监听,
}
}
我发现在这里设置contentBas之后好像在打开8080之后在找bundle.js找不到。
我心血来潮把整个devServer都删掉了,就能成功的搭建本地的服务器了。很奇怪。
至于为什么还是没有找到答案。