react-injectables
Version:
Explicitly inject Components into any part of your React render tree.
78 lines (72 loc) • 1.69 kB
JavaScript
import webpack from 'webpack';
import path from 'path';
import WebpackStatsPlugin from 'stats-webpack-plugin';
const env = process.env.NODE_ENV;
const generateStats = process.env.WEBPACK_STATS || false;
const libraryName = `react-injectables`;
const outputFileName = `${libraryName}.js`;
const reactExternal = {
root: `React`,
commonjs2: `react`,
commonjs: `react`,
amd: `react`
};
const config = {
entry: path.resolve(__dirname, `./src/index.js`),
externals: {
react: reactExternal
},
module: {
preLoaders: [
{ test: /\.js$/, loaders: [`eslint-loader`], exclude: /node_modules/ }
],
loaders: [
{
test: /\.js$/,
loaders: [`babel-loader`],
include: [path.resolve(__dirname, `./src`)],
exclude: /node_modules/
}
]
},
output: {
path: path.resolve(__dirname, `./lib`),
filename: outputFileName,
library: libraryName,
libraryTarget: `umd`,
umdNamedDefine: true
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env)
})
],
eslint: {
failOnError: true,
failOnWarning: true
}
};
if (env === `production`) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false
}
})
);
}
if (generateStats) {
config.plugins.push(
new WebpackStatsPlugin(`stats.json`, {
chunkModules: true,
exclude: [/node_modules[\\\/]react/]
})
);
}
export default config;