Skip to content

Instantly share code, notes, and snippets.

@rigobertocontreras
Last active August 14, 2019 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rigobertocontreras/190c2ee8828ae97464def1fda7d8bb36 to your computer and use it in GitHub Desktop.
Save rigobertocontreras/190c2ee8828ae97464def1fda7d8bb36 to your computer and use it in GitHub Desktop.
whatwg-fetch polyfill
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