zoukankan      html  css  js  c++  java
  • react_webpack.prod.config

    const path = require('path');
    const webpack = require('webpack');
    const jquery = require('jquery');
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const ExtractTextPlugin = require("extract-text-webpack-plugin");
    const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
    
    module.exports = {
        entry: ['./src/app.js'],
        output: {
            path: path.join(__dirname, 'dist'),
            publicPath: "/dist",
            filename: 'js/app.js'
        },
        module: {
            rules: [
                {
                    test: /.js[x]?$/,
                    exclude: /(node_modules)/,
                    use: {
                        loader: 'babel-loader',
                        options: {
                            presets: ['env', 'react'],
                            plugins: [
                                [
                                    "import",
                                    [
                                        {
                                            "libraryName": "antd",
                                            "style": true
                                        }
                                    ]
                                ]
                            ]
                        }
                    }
                },
                {
                    test: /.css$/,
                    loader: ExtractTextPlugin.extract({
                        use: "css-loader",
                        fallback: "style-loader"
                    })
                },
                {
                    test: /.scss$/,
                    loader: ExtractTextPlugin.extract({
                        use: 'css-loader!sass-loader',
                        fallback: 'style-loader'
                    })
                },
                {
                    test: /.less$/,
                    loader: ExtractTextPlugin.extract({
                        use: [{
                            loader: 'css-loader'
                        }, {
                            loader: 'less-loader',
                            options: {
                                javascriptEnabled: true,
                                modifyVars: {
                                    '@icon-url': '"~antd-iconfont/iconfont"',
                                }
                            }
                        }],
                        fallback: 'style-loader'
                    })
                },
                {
                    test: /.(gif|jpg|png|woff|svg|eot|ttf)??.*$/,
                    use: [{
                        loader: 'url-loader',
                        options: {
                            name: '[path][name].[ext]',
                            limit: 2000
                        }
                    }]
                }
            ]
        },
        resolve: {
            alias: {
                node_modules: path.join(__dirname, '/node_modules'),
                component: path.join(__dirname, '/src/component'),
                util: path.join(__dirname, '/src/util'),
                page: path.join(__dirname, '/src/page'),
                service: path.join(__dirname, '/src/service'),
                modals: path.join(__dirname, '/src/modals'),
                styles: path.join(__dirname, '/src/styles'),
                images: path.join(__dirname, '/src/images'),
                reduxModel: path.join(__dirname, '/src/reduxModel')
            }
        },
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                name: 'common',
                filename: 'js/base.js'
            }),
            new HtmlWebpackPlugin({
                template: './src/index.html',
                filename: 'index.html',
                //favicon: './favicon.ico'
            }),
            new ExtractTextPlugin("[name].css"),
            new webpack.ProvidePlugin({
                _: 'lodash',
                $: 'jquery',
                jQuery: 'jquery'
            }),
            new UglifyJSPlugin({
                cache: true,
                parallel: 2
            }),
            new webpack.DefinePlugin({
                'process.dev.NODE_ENV': JSON.stringify('production')
            })
        ],
        devServer: {
            port: '8088', //设置端口号
            historyApiFallback: {
                index: '/dist/index.html'
            },
            open: true,
            proxy: {
                '/react-redux-api/*': {
                    target: 'http://localhost:3000',
                    secure: false
                },
                '/api/*': {
                    target: 'http://localhost:12306',
                    secure: false
                }
            }
        }
    };
  • 相关阅读:
    git
    RT-Thread 4.0 + STM32F407 学习笔记1
    C#串口通信及数据表格存储
    NRF52832初步使用
    ubuntu终端下快捷键之--字体放大缩小
    微信公众号开发被动回复用户消息,回复内容Content使用了" "换行符还是没有换行
    python2018年秋季调研
    python图像处理模块Pillow--Image模块
    linux查看文件命令tail的使用
    使用xadmin更新数据时,报错expected string or bytes-like object
  • 原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/9208934.html
Copyright © 2011-2022 走看看