Last active
August 14, 2019 17:16
-
-
Save rigobertocontreras/190c2ee8828ae97464def1fda7d8bb36 to your computer and use it in GitHub Desktop.
whatwg-fetch polyfill
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 webpack = require('webpack'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const path = require('path'); | |
const config = { | |
entry: { | |
app: [ | |
'webpack/hot/dev-server', | |
"./src/app.js" | |
] | |
}, | |
stats: { | |
colors: true, | |
reasons: true, | |
}, | |
debug: true, | |
resolve: { | |
extensions: ['', '.js', '.jsx', '.scss'], | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.s?css$/, | |
exclude: /node_modules/, | |
loaders: [ | |
'style', | |
'css', | |
'autoprefixer?browsers=last 2 version', | |
'sass?' + ['outputStyle=nested'].join('&') | |
] | |
}, | |
{ test: /\.jsx?$/, loaders: ['react-hot', 'babel'], exclude: /node_modules/ }, | |
{ test: /\.json$/, loader: 'json' }, | |
] | |
}, | |
output: { | |
path: __dirname + '/build', | |
publicPath: '/', | |
filename: '[name].[hash].js', | |
chunkFilename: '[id].[hash].js' | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.ProvidePlugin({ | |
// for IE11 | |
Promise: 'es6-promise', | |
//or | |
Promise: 'imports-loader?this=>global!exports-loader?global.Promise!es6-promise', | |
// imports-loaders and exports-loader need to be installed | |
fetch: 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch', | |
}), | |
new HtmlWebpackPlugin({ | |
template: path.resolve('public', 'index.html'), | |
webpackDevServer: '/webpack-dev-server.js' | |
}) | |
] | |
} | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment