Skip to content

Instantly share code, notes, and snippets.

@markthomas93
Forked from jaysoo/webpack.config.js
Created October 8, 2018 08:43
Show Gist options
  • Save markthomas93/da5606b8ecb76229a7939ccb8a1973b3 to your computer and use it in GitHub Desktop.
Save markthomas93/da5606b8ecb76229a7939ccb8a1973b3 to your computer and use it in GitHub Desktop.
Minimum webpack config for development
// 1. npm init
// 2. npm install --save webpack webpack-dev-server babel-loader babel-preset-es2015
// 3. mkdir dist && touch index.html
// 4. Include `<script src="/bundle.js"></script>` inside index.html
// 5. mkdir src && touch src/index.js
// 6. Add some code to index.js (e.g. `console.log('Hello, World!'))
// 7. npm start
// 8. Browse to http://localhost:8080/dist/
const webpack = require('webpack')
module.exports = {
context: __dirname + "/src",
entry: "./index",
output: {
path: __dirname + "/dist",
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015']
}
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment