Code Monkey home page Code Monkey logo

webpackreact's Introduction

The basic use of webpack and react

webpack.config.js

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
	
    entry: {
        index: './src/script/education.js',
  	//vendor: ["react", "react-dom"]
    },

    output: {
        path: __dirname + '/build',
        //filename: 'education_[hash].js'
        filename: 'education.js',
        publicPath: "/build",
        //chunkFilename: '[name].[chunkhash:5].chunk.js',
        chunkFilename: "[name].js" 
    },
  
    devServer: {
        contentBase: './build',
        host: 'localhost',
        port: 9000,
        historyApiFallback: false,
        proxy: {
            '/api': {
                target: 'http://dev2.3-api.zuren8.com/',
                pathRewrite: {'^/api': ''},
                changeOrigin: true
            }
        }
    },
  
    module: {
        loaders: [
        {
            test: /\.css$/,
            loader: ExtractTextPlugin.extract({
                fallback: 'style-loader',
                use: 'css-loader'
            })
        },
        {
            test: /\.scss$/,
            loader: ExtractTextPlugin.extract({
                fallback: 'style-loader',
                use: 'css-loader!sass-loader'
            })
        },
        {
            test: /\.js$/,
            exclude: /node_modules/,
            loader: 'react-hot-loader!babel-loader'
        }
        ]
    },
  
    plugins: [
        /*new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            }
        }),*/
  
        new HtmlWebpackPlugin({
            template: './src/index.ejs',
            filename: 'index.html',
            title: 'name'
        }),
    
        new ExtractTextPlugin({
            //filename: 'education_[hash].css',
            filename: 'education.css',
            disable: false,
            allChunks: true
        }),
    
        /*new OpenBrowserPlugin({
            url: 'http://localhost:9000'
        }),*/
    
        /*new webpack.optimize.CommonsChunkPlugin({
            names: 'vendor',
            filename: 'vendor.js'
	}),*/
    ],
  
    externals: {
        'react': 'window.React',
        'react-dom': 'window.ReactDOM',
        'react-router': 'window.ReactRouter',
        'redux': 'window.Redux',
        'react-redux': 'window.ReactRedux',
        "jquery": 'window.$'
    }
  
}

webpackreact's People

Contributors

tiger986 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.