const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const eslintPath = path.join(__dirname, '.eslintrc.js');

const config = {
    entry: {
        index: path.resolve(__dirname, './app.jsx'),
        vendors: [
         'react',
            'react-dom',
         'react-color',
           'axios',
           'echarts',
           'babel-polyfill'
        ]
    },
    output: {
      path: path.resolve(__dirname, 'build'),
      chunkFilename: '[name].bundle.js',
      filename: '[name].bundle.js'
      // filename: '[name].bundle[chunkHash:5].js'
    },
    module: {
      rules: [
        // {
          // enforce: "pre",
          // test: /\.js$/,
          // exclude: /node_modules/,
          // loader: "eslint-loader",
          // options: {
          // configFile:path.join(__dirname, '.eslintrc.js'),
          // formatter: require("eslint-friendly-formatter"),
          // // eslintPath: path.join(__dirname, '.eslintrc.js'),
          // emitError: true
          // }
        // },
        {
          test: /\.jsx?$/,
          exclude: /node_modules/,
          loader: "babel-loader",
        },
        // {
          // test: /\.jsx?$/,
          // loader: ['babel-loader','eslint-loader'],
          // exclude: /node_modules/,
        // },
        {
         test: /(\.(png|jpg|ttf|woff|svg|eot)$)/,
         use: [{
          loader: 'file-loader',
          options: {
            name: '[path][name].[ext]',
            outputPath: 'resource/'
          }
           }]
        },
        {
          test: /\.css$/,
          use: ExtractTextPlugin.extract({
            fallback: "style-loader",
            use: "css-loader"
          })
        },

        ]
       },
    resolve: {
      extensions: ['.js', '.jsx'],
      alias:{
        'corejs': path.resolve('./corejs'),
       }
    },
    plugins: [
      new webpack.DefinePlugin({
        'process.env': {
        'NODE_ENV': JSON.stringify('development')
      }
    }),
    new ExtractTextPlugin("styles.css"),
    //生成模板
    new HtmlWebpackPlugin({
      template: './template.html',
      filename: 'index.html',
      inject: true,
      hash: false
    }),
    //添加代码标注
    new webpack.BannerPlugin('This file is created by xdataInsight group'),
    //提取合并共用js库
    // new webpack.optimize.CommonsChunkPlugin({ name: 'vendors', filename: 'vendors.[hash:8].min.js' }),
    ],
    devtool: 'eval-source-map',
    devServer: {
      contentBase: './',
      historyApiFallback: true,
      // hot: true,
      inline: true,
      disableHostCheck: true,
      proxy: {  //代理
        '/xdatainsight/*': {
          target: 'http://balabala:41116',
          secure: false,
          auth: 'admin:admin'
        }
      }
    }
};
module.exports = config;

webpack配置(使用react,es6的项目)的更多相关文章

  1. webpack 配置 (支持 React SCSS ES6 编译打包 和 模块热更新 / 生成SourceMap)

    1.首先是目录结构 |-node_modules/ #包文件 |-build/ #静态资源生成目录 |-src/ #开发目录 |-js/ |-index.js #入口文件 |-app.js #Reac ...

  2. react基于webpack和babel以及es6的项目搭建

    项目demo地址https://github.com/aushion/webpack_reac_config 1.打开命令提示窗口,输入 mkdir react_test cd react_test ...

  3. 基于 Webpack 4 和 React hooks 搭建项目

    面对日新月异的前端,我表示快学不动了

  4. [webpack] 配置react+es6开发环境

    写在前面 每次开新项目都要重新安装需要的包,简单记录一下. 以下仅包含最简单的功能: 编译react 编译es6 打包src中入口文件index.js至dist webpack配置react+es6开 ...

  5. webpack踩坑之路——构建基本的React+ES6项目

    转自:http://www.cnblogs.com/ghost-xyx/p/5483464.html webpack是最近比较火的构建工具,搭配上同样比较火的ReacJS与ES6(ES2015)一定是 ...

  6. React+ES6+Webpack环境配置

    转自http://www.cnblogs.com/chenziyu-blog/p/5675086.html 参考http://www.tuicool.com/articles/BrAVv2y Reac ...

  7. Webpack+React+ES6 最新环境搭建和配置(2017年)

    刚刚学习React,发现React在ES6下的语法才是本体,结合ES6新的语言特性,使组件化开发显得更加直观.而且现在的Angular2也开始使用支持强类型的TypeScript,转译(transpi ...

  8. Webpack+React+ES6开发模式入门指南

    React无疑是今年最火的前端框架,github上的star直逼30,000,基于React的React Native的star也直逼20,000.有了React,组件化似乎不再步履蹒跚,有了Reac ...

  9. webpack+react+es6开发模式

    一.前言 实习了两个月,把在公司用到的前端开发模式做个简单的整理.公司里前端开发模式webpack+react+redux+es6,这里去掉了redux. webpack, react, redux等 ...

随机推荐

  1. 一、Redis的安装

    1.下载.解压.编译.安装 # 下载地址 wget http://download.redis.io/redis-stable.tar.gz # 解压 tar xzf redis-stable.tar ...

  2. Spring整合Struts2的两种方式

    https://blog.csdn.net/cuiyaoqiang/article/details/51887594

  3. Pydiction补全插件

    Pydiction不需要安装,所有没有任何依赖包问题,Pydiction主要包含三个文件. python_pydiction.vim -- Vim plugin that autocompletes ...

  4. 【纪中集训】2019.08.01【NOIP提高组】模拟 A 组TJ

    T1 Description 给定一个\(N*N(N≤8)\)的矩阵,每一格有一个0~5的颜色.每次可将左上角的格子所在连通块变为一种颜色,求最少操作数. Solution IDA*=启发式迭代加深 ...

  5. Druid动态数据源配置

    上文已经讲了单个数据源的Druid的配置(http://www.cnblogs.com/nbfujx/p/7686634.html) Druid动态数据源配置 主要是继承AbstractRouting ...

  6. OC学习篇之---谓词(NSPredicate)

    在前一篇文章中我们介绍了OC中一个重要技术通知:http://blog.csdn.net/jiangwei0910410003/article/details/41923401,今天我们在来看一下OC ...

  7. paper 140:TLD视觉跟踪算法(超棒)

    我是看了这样的一个视频:http://www.56.com/u83/v_NTk3Mzc1NTI.html 然后在准备针对TLD视觉跟踪算法来个小的总结. 以下博文转自:http://blog.csdn ...

  8. 导入csv 到mysql数据库

    1.查询导入数据存放位置 show variables like '%secure%'; +--------------------------+-----------------------+ | ...

  9. centos7 yum 安装最新的nginx 1.16

    参考:https://www.cnblogs.com/opsprobe/p/10773582.html nginx官方文档说明:http://nginx.org/en/linux_packages.h ...

  10. java.lang.IllegalAccessException: Class XXXcan not access xxx with modifiers "private"

    field 或者 method 是 provate的 field.setAccessible(true); method.setAccessible(true); 有时候是因为 newinstance ...