webio-node/webpack.config.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-03-22 05:35:45 +00:00
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HTMLWebpackPluginConfig = new HtmlWebpackPlugin({template: `${__dirname}/src/index.html`, filename: "index.html", inject: 'body'});
const envToObj = {
NODE_ENV: process.env.NODE_ENV || 'development'
}
let obj = {};
for(let i in envToObj){
obj[i] = JSON.stringify(envToObj[i]);
}
module.exports = {
entry: {
index: `${__dirname}/src/index.js`,
admin: `${__dirname}/src/admin.js`
},
output: {
path: `${__dirname}/public/js`,
filename: '[name]_bundle.js'
},
module: {
// preLoaders: [
// {
// test: /\.jsx$|\.js$/,
// loader: 'eslint-loader',
// include: `${__dirname}/src`,
// exclude: /bundle\.js$/
// }
// ],
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react', 'stage-1']
}
}
]
},
devServer: {
inline: true,
contentBase: './src',
port: 8008
},
plugins: [
new webpack.DefinePlugin({
'process.env': obj
})
]
}