1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- const path = require('path');
- const webpack = require('webpack');
- const resolve = dir => {
- return path.join(__dirname, dir)
- };
- // 线上打包路径,请根据项目实际线上情况
- const BASE_URL = process.env.NODE_ENV === 'production' ? '/api' : '/api';
- module.exports = {
- publicPath: BASE_URL,
- outputDir: 'dist', // 打包生成的生产环境构建文件的目录
- assetsDir: '', // 放置生成的静态资源路径,默认在outputDir
- indexPath: 'index.html', // 指定生成的 index.html 输入路径,默认outputDir
- pages: undefined, // 构建多页
- productionSourceMap: false, // 开启 生产环境的 source map?
- chainWebpack: config => {
- // 配置路径别名
- config.resolve.alias
- .set('@', resolve('src'))
- .set('_c', resolve('src/components'))
- },
- css: {
- modules: false, // 启用 CSS modules
- extract: true, // 是否使用css分离插件
- sourceMap: false, // 开启 CSS source maps?
- loaderOptions: {} // css预设器配置项
- },
- devServer: {
- open: true,
- port: 8000, // 端口
- disableHostCheck: false,
- https: false,
- hotOnly: false,
- proxy:{
- '/api': {
- target: 'http://192.168.1.200:8080', // 设置代理
- ws: true,
- changeOrigin: true,
- pathRewrite: {
- '^/api': '/'
- }
- }
- }
- },
- configureWebpack: {
- plugins: [
- new webpack.ProvidePlugin({
- $: "jquery",
- jQuery: "jquery",
- "windows.jQuery": "jquery"
- })
- ]
- }
- };
|