Skip to content

Instantly share code, notes, and snippets.

@codyogden
Created September 25, 2018 18:34
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 codyogden/df6740eb31aede71cde05c3cef00c2a1 to your computer and use it in GitHub Desktop.
Save codyogden/df6740eb31aede71cde05c3cef00c2a1 to your computer and use it in GitHub Desktop.
const webpack = require('webpack');
module.exports = (env, argv) => {
const config = {
entry: './src/App.jsx',
output: {
path: __dirname,
publicPath: '/',
filename: '[name].js',
},
module: {
rules: [{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx'],
alias: {},
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
devServer: {
contentBase: './',
hot: true,
},
};
if (argv.mode === 'production') {
config.resolve.alias.react = 'preact-compat';
config.resolve.alias['react-dom'] = 'preact-compat';
}
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment