UNPKG

932 BJavaScriptView Raw
1/* eslint-env node */
2const path = require('path');
3const webpack = require('webpack');
4
5function getConfig(env) {
6 const config = {
7 mode: env,
8 entry: './lib/ReactCrop',
9 output: {
10 path: path.resolve('dist'),
11 library: 'ReactCrop',
12 libraryTarget: 'umd',
13 filename: env === 'production' ? 'ReactCrop.min.js' : 'ReactCrop.js',
14 globalObject: 'this',
15 },
16 target: 'web',
17 externals: {
18 react: {
19 root: 'React',
20 commonjs: 'react',
21 commonjs2: 'react',
22 amd: 'react',
23 },
24 },
25 module: {
26 rules: [
27 {
28 test: /\.js$/,
29 exclude: /node_modules/,
30 use: 'babel-loader',
31 },
32 ],
33 },
34 plugins: [
35 new webpack.DefinePlugin({
36 'process.env.NODE_ENV': JSON.stringify(env),
37 }),
38 ],
39 };
40
41 return config;
42}
43
44module.exports = [getConfig('development'), getConfig('production')];