Created
          April 9, 2017 18:40 
        
      - 
      
 - 
        
Save lazandrei19/e2e0ffcb762998dcbfdb70b1cdaa22a6 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              Show hidden characters
| { | |
| "presets": [ | |
| ["stage-0"], | |
| ["env", {"modules": false}], | |
| "react" | |
| ], | |
| "plugins": [ | |
| "react-hot-loader/babel" | |
| //"react-css-modules" | |
| ] | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | module.exports = { | |
| plugins: [ | |
| require ('autoprefixer') | |
| ] | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const path = require('path'); | |
| const webpack = require('webpack'); | |
| const env = require ('node-env-file'); | |
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
| const ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
| env (path.join(__dirname, ".env")); | |
| const isProd = process.env.NODE_ENV === 'prod'; | |
| const prodCss = ExtractTextPlugin.extract({ | |
| fallback: 'style-loader', | |
| use: [{ | |
| loader: 'css-loader', | |
| options: { | |
| modules: true, | |
| localIdentName: '[path][name]__[local]--[hash:base64:5]' | |
| }}, 'postcss-loader', | |
| 'sass-loader' | |
| ], | |
| publicPath: '/dist' | |
| }); | |
| const devCss = [ | |
| 'style-loader', { | |
| loader: 'css-loader', | |
| options: { | |
| modules: true, | |
| localIdentName: '[path][name]__[local]--[hash:base64:5]' | |
| } | |
| }, | |
| 'postcss-loader', | |
| 'sass-loader' | |
| ]; | |
| const css = isProd? prodCss : devCss; | |
| const id = isProd? '[hash]' : 'bundle'; | |
| module.exports = { | |
| entry: [ | |
| 'react-hot-loader/patch', | |
| 'webpack-dev-server/client?http://localhost:8080', | |
| 'webpack/hot/only-dev-server', | |
| './src/app.js', | |
| ], | |
| output: { | |
| path: path.join (__dirname, 'dist'), | |
| filename: '[name].' + id + '.js', | |
| chunkFilename: '[id].' + id + '.js' | |
| }, | |
| module: { | |
| rules: [{ | |
| test: /\.(sa|s?c)ss$/, | |
| use: css | |
| }, { | |
| test: /\.jsx?$/, | |
| exclude: /node_modules/, | |
| use: 'babel-loader' | |
| }] | |
| }, | |
| plugins: [ | |
| new HtmlWebpackPlugin ({ | |
| title: 'Webpack test page', | |
| template: 'src/index.html', | |
| cache: true | |
| }), | |
| new ExtractTextPlugin({ | |
| filename: '[name].' + id + '.css', | |
| disable: !isProd, | |
| allChunks: true | |
| }), | |
| new webpack.HotModuleReplacementPlugin(), | |
| new webpack.NamedModulesPlugin(), | |
| new webpack.optimize.CommonsChunkPlugin({ | |
| name: 'vendor', | |
| minChunks: function (module) { | |
| return module.context && module.context.indexOf('node_modules') !== -1; | |
| } | |
| }) | |
| ], | |
| devServer: { | |
| compress: true, | |
| contentBase: path.join (__dirname, 'assets'), | |
| overlay: true, | |
| hot: !isProd, | |
| proxy: { | |
| '/api': { | |
| target: 'http://localhost:3000/', | |
| secure: false | |
| } | |
| } | |
| } | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment