123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- const path = require('path');
- const join = path.join;
- const resolve = path.resolve;
- const webpack = require('webpack');
- const tmpdir = require('os').tmpdir;
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const htmlPlugin = new HtmlWebpackPlugin({
- template: './src/index.html',
- filename: './index.html',
- favicon: './favicon.ico'
- });
- const config = require('./config/env-config');
- // mock data
- const appData = require('./config/data.json');
- const statistic = appData.statistic;
- const user = appData.user;
- const category = appData.category;
- module.exports = {
- entry: './src/App.jsx',
- resolve: {
- alias: {
- page: path.resolve(__dirname, 'src/page'),
- component: path.resolve(__dirname, 'src/component'),
- util: path.resolve(__dirname, 'src/util'),
- api: path.resolve(__dirname, 'src/api')
- },
- modules: ['node_modules', join(__dirname, '../node_modules')],
- extensions: ['.web.tsx', '.web.ts', '.web.jsx', '.web.js', '.ts', '.tsx', '.js', '.jsx', '.json']
- },
- output: {
- publicPath: '/'
- },
- module: {
- rules: [
- {
- test: /\.jsx?$/,
- exclude: /node_module/,
- use: {
- loader: 'babel-loader',
- options: {
- presets: ['react', 'env'],
- cacheDirectory: true,
- cacheDirectory: tmpdir(),
- presets: [
- require.resolve('babel-preset-es2015-ie'),
- require.resolve('babel-preset-react'),
- require.resolve('babel-preset-stage-0')
- ],
- plugins: [
- require.resolve('babel-plugin-add-module-exports'),
- require.resolve('babel-plugin-transform-decorators-legacy'),
- ['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }]
- ]
- }
- }
- },
- {
- test: /\.css$/,
- loader: 'style-loader!css-loader'
- },
- {
- test: /\.(eot|woff|woff2|ttf)/,
- loader: 'url-loader?limit=30000&name=fonts/[hash:8].[name].[ext]'
- },
- // {
- // test: /\.css$/,
- // exclude: /node_module/,
- // use: [
- // {
- // loader: 'style-loader'
- // },
- // {
- // loader: 'css-loader',
- // options: {
- // modules: true,
- // importLoaders: 1,
- // sourceMap: true,
- // localIdentName: '[path][name]__[local]--[hash:base64:5]'
- // }
- // }
- // ]
- // },
- {
- test: /\.scss$/,
- use: [
- {
- loader: 'style-loader'
- },
- {
- loader: 'css-loader'
- },
- {
- loader: 'sass-loader'
- },
- {
- loader: 'sass-resources-loader',
- options: {
- resources: './src/style/resources.scss'
- }
- }
- ]
- }
- ]
- },
- devServer: {
- port: 8080,
- historyApiFallback: true,
- before(app) {
- app.get('/api/statistic', function(req, res) {
- res.json(statistic);
- });
- },
- proxy: {
- '/manage': {
- // target: 'https://bird.ioliu.cn/v1?url=http://adminv2.happymmall.com/manage/',
- target: 'http://adminv2.happymmall.com',
- changeOrigin: true
- // target: 'https://www.baidu.com',
- // pathRewrite: { '^/manage': '' },
- // secure: false
- },
- '/user/logout.do': { target: 'http://adminv2.happymmall.com', changeOrigin: true }
- }
- },
- plugins: [
- htmlPlugin,
- new webpack.DefinePlugin({
- 'process.env.BASE_URL': '"' + process.env.BASE_URL + '"'
- })
- ]
- };
|