zoukankan      html  css  js  c++  java
  • react-webpack(二)

    const path = require('path');
    const webpack = require('webpack');
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const ExtractTextPlugin = require("extract-text-webpack-plugin");
    
    module.exports = {
        entry: './src/app.jsx',
        output: {
            path: path.join(__dirname, 'dist'),
            filename: 'js/app.js'
        },
        module: {
            rules: [
                {
                    test: /.jsx$/,
                    exclude: /(node_modules)/,
                    use: {
                        loader: 'babel-loader',
                        options: {
                            presets: ['env', 'react']
                        }
                    }
                },
                {
                    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: /.(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'),
                util: path.join(__dirname, '/src/util'),
                component: path.join(__dirname, '/src/component'),
                service: path.join(__dirname, '/src/service'),
                page: path.join(__dirname, '/src/page'),
                styles: path.join(__dirname, '/src/styles')
            }
        },
        devServer: {
            port: '8088', //设置端口号
                          // 路径的配置
            historyApiFallback: {
                index: '/dist/index.html'
            },
            proxy: {
                '/manage': {
                    target: 'http://test.happymmall.com/',
                    changeOrigin: true
                },
                '/user/logout.do': {
                    target: 'http://test.happymmall.com/',
                    changeOrigin: true
                }
            }
        },
        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")
        ]
    };
  • 相关阅读:
    【转】Hibernate 配置
    【转】关于Log4j
    This project is not a myeclipse hibernate project . Assuming Hibernate 3 capabilities configuration editor
    java集合框架分析
    鸡蛋篮子与格子取数
    贪心与回溯与DP
    NP问题
    子集生成和全排列
    JDK动态代理实现原理(转)
    java类初始化/生命周期及反射及动态代理
  • 原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/8557289.html
Copyright © 2011-2022 走看看