Skip to content

Instantly share code, notes, and snippets.

@carloslenondavis
Created September 25, 2018 18:48
Show Gist options
  • Save carloslenondavis/ee0fd46d9738cf82bf4467d860052171 to your computer and use it in GitHub Desktop.
Save carloslenondavis/ee0fd46d9738cf82bf4467d860052171 to your computer and use it in GitHub Desktop.
Webpack config boilerplate
const path = require('path');
const webpack = require('webpack');
const devMode = process.env.NODE_ENV !== 'production';
const publishFolder = 'publish'; // dir were bundle will be allowed.
module.exports = {
mode: 'development',
devtool: 'cheap-eval-source-map',
entry: [
//add your entry files or file
],
output: {
path: path.join(__dirname, publishFolder),
filename: '' //bundle file name e.g. 'bundle.js'
},
resolve: {
alias: {
component: path.join(__dirname, 'src')
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [require('@babel/plugin-proposal-object-rest-spread')]
}
}
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
devServer: {
contentBase: `${publishFolder}/`,
compress: true
},
watchOptions: {
ignored: [
/node_modules/,
'.src/**/*.test.js'
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment