1 Star 0 Fork 0

ltara / cms-spa

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
ltara 提交于 2020-08-11 12:57 . 2
const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugins = require('./node_modules/vue-loader/lib/plugin')
const webpack = require('webpack')
const {
options
} = require('less')
module.exports = {
entry: './src//main.js',
output: {
path: path.join(__dirname, './dist/'), // 出口路径必须是个绝对路径
filename: 'bundle.js', // 打包结果的文件名
},
devtool: 'eval-cheap-module-source-map',
mode: 'development',
plugins: [
new htmlWebpackPlugin({
template: './index.html'
}),
new VueLoaderPlugins(),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
],
devServer: {
historyApiFallback: true,
contentBase: './',
hot: true,
proxy: {
'/api': { // api表示当前项目请求的key
target: 'http://localhost:3000', // 代理服务器路径
pathRewrite: {
'^/api': '/'
}, // 重写路径
changeOrigin: true
}
}
},
externals: {
// 前面是包名,后面是包里导出的全局接口对象
vue: 'Vue',
'vue-router': 'VueRouter',
axios: 'axios',
lodash: '_'
},
module: {
rules: [
//css
{
test: /\.css$/,
use: [
//这两个顺序不能反了
'style-loader',
'css-loader'
]
},
//img
{
test: /\.(png|jpg|svg|gif)$/,
use: {
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
esModule: false // 防止出现打包后请求的资源变成 [object-object]
}
}
},
//less
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader'
]
},
//js(bable)
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
//vue
{
test: /\.vue$/,
use: ['vue-loader']
}
]
}
}
1
https://gitee.com/ltara/cms-spa.git
git@gitee.com:ltara/cms-spa.git
ltara
cms-spa
cms-spa
master

搜索帮助