/* global __dirname */
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var dir_js = path.resolve(__dirname, 'js');
var dir_html = path.resolve(__dirname, 'html');
var dir_build = path.resolve(__dirname, 'build');
module.exports = {
entry: path.resolve(dir_js, 'main.js'),
output: {
path: dir_build,
filename: 'bundle.js'
},
devServer: {
contentBase: dir_build,
},
module: {
loaders: [
{
loader: 'babel-loader',
test: dir_js,
}
]
},
plugins: [
// Simply copies the files over
new CopyWebpackPlugin([
{ from: dir_html } // to: output.path
]),
// Avoid publishing files when compilation fails
new webpack.NoErrorsPlugin()
],
stats: {
// Nice colored output
colors: true
},
// Create Sourcemaps for the bundle
devtool: 'source-map',
}
{
"devDependencies": {
"babel-loader": "^6.1.0",
"babel-preset-es2015": "^6.1.18",
"babel-polyfill": "^6.3.14",
"webpack": "^1.12.6",
"webpack-dev-server": "^1.12.1",
"copy-webpack-plugin": "^0.2.0"
},
"scripts": {
"build": "webpack",
"watch": "webpack --watch",
"start": "webpack-dev-server --hot --inline"
},
"babel": {
"presets": ["es2015"]
}
}