var path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
var config = {
// devtool: 'inline-source-map',
mode: "production",
entry: {
main: './main'
},
output: {
path: path.join(__dirname, './dist'),
publicPath: '/dist/',
filename: 'main.js'
},
devServer: {
compress: false,
proxy: {
'/api': {
//要访问的跨域的域名
target: 'http://localhost/api',
changeOrigin: true,
secure: false,
pathRewrite: {
'^/api': ''
}
}
}
},
module: {
rules: [{
test: /\.vue$/,
use: [{
loader: "vue-loader",
options: {
loaders: {
css: ExtractTextPlugin.extract({
use: "css-loader",
fallback: "vue-style-loader"
})
}
}
},
{
loader: "iview-loader",
options: {
prefix: false
}
}
]
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /iview\/.*?js$/,
loader: "babel-loader"
},
{
test: /iview.src.*?js$/, //为了兼容ie,否则在ie浏览器无法预览iview组件
use: [{
loader: "babel-loader"
}]
},
{
//此处配置为iview的注意点,如果不配置的话 无法再Js文件中加载iview.css文件;其次如果使用url-loader无法加载的话,会使用file-loader进行文件加载
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: "url-loader?limit=1024"
},
]
},
plugins: [
new VueLoaderPlugin(),
new ExtractTextPlugin("styles.css"),
]
}
module.exports = config;