emails-renderer/webpack.config.js

103 lines
2.3 KiB
JavaScript
Raw Normal View History

2016-08-28 18:55:56 +05:30
/* eslint-env node */
2016-08-30 12:32:00 +05:30
const path = require('path');
2016-08-28 18:55:56 +05:30
2016-08-30 12:32:00 +05:30
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
2016-08-28 18:55:56 +05:30
const rootPath = path.resolve('./src');
2016-08-30 12:32:00 +05:30
const isProduction = process.env.NODE_ENV === 'production';
2016-08-28 18:55:56 +05:30
process.env.NODE_ENV = isProduction ? 'production' : 'development';
2016-09-04 21:54:50 +05:30
const webpackConfig = {
2016-08-28 18:55:56 +05:30
entry: {
2016-08-30 12:32:00 +05:30
app: path.join(__dirname, 'src')
2016-08-28 18:55:56 +05:30
},
2016-08-30 12:32:00 +05:30
target: isProduction ? 'node' : 'web',
2016-08-28 18:55:56 +05:30
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
2016-08-30 12:32:00 +05:30
filename: isProduction ? '[name].js' : '[name].js?[hash]',
libraryTarget: isProduction ? 'commonjs' : undefined
2016-08-28 18:55:56 +05:30
},
resolve: {
root: rootPath,
extensions: ['', '.js', '.jsx']
},
devServer: {
host: 'localhost',
port: 8080,
hot: true,
inline: true,
historyApiFallback: true
},
2016-09-04 21:54:50 +05:30
devtool: isProduction ? 'eval' : false,
2016-08-28 18:55:56 +05:30
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
},
__DEV__: !isProduction,
__PROD__: isProduction
}),
new HtmlWebpackPlugin({
template: 'src/index.ejs',
favicon: 'src/favicon.ico',
filename: 'index.html',
2016-08-30 12:32:00 +05:30
inject: false
2016-08-28 18:55:56 +05:30
}),
new webpack.ProvidePlugin({
2016-08-30 12:32:00 +05:30
React: 'react'
})
],
2016-08-28 18:55:56 +05:30
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.(png|gif|jpg|svg)$/,
2016-09-04 21:54:50 +05:30
loader: 'url',
2016-08-28 18:55:56 +05:30
query: {
name: 'assets/[name].[ext]?[hash]'
}
},
{
test: /\.json$/,
exclude: /(intl|font)\.json/,
loader: 'json'
},
{
test: /\.intl\.json$/,
loader: 'babel!intl!json'
}
]
},
resolveLoader: {
alias: {
intl: path.resolve('webpack-utils/intl-loader')
}
}
};
if (!isProduction) {
webpackConfig.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
);
}
module.exports = webpackConfig;