Created
September 25, 2018 18:48
-
-
Save carloslenondavis/ee0fd46d9738cf82bf4467d860052171 to your computer and use it in GitHub Desktop.
Webpack config boilerplate
This file contains 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 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