emoji-mart-lazyload/spec/webpack.config.js

62 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-05-31 14:36:52 +00:00
var path = require('path')
var pack = require('../package.json')
var webpack = require('webpack')
2017-10-07 04:02:02 +00:00
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
2016-05-31 14:36:52 +00:00
2017-10-07 04:02:02 +00:00
var PROD = process.env.NODE_ENV === 'production'
var TEST = process.env.NODE_ENV === 'test'
var config = {
2016-05-31 14:36:52 +00:00
entry: path.resolve('src/index.js'),
output: {
2017-11-09 06:41:57 +00:00
path: path.resolve('spec'),
filename: 'bundle.js',
2016-07-27 15:35:12 +00:00
library: 'EmojiMart',
2016-05-31 14:36:52 +00:00
libraryTarget: 'umd',
},
externals: [],
2016-05-31 14:36:52 +00:00
module: {
2017-09-17 07:33:59 +00:00
rules: [
2016-05-31 14:36:52 +00:00
{
test: /\.js$/,
2017-09-17 07:33:59 +00:00
use: 'babel-loader',
2017-11-09 06:41:57 +00:00
include: [path.resolve('src'), path.resolve('spec')],
2016-06-02 15:26:48 +00:00
},
2016-05-31 14:36:52 +00:00
],
},
resolve: {
2017-09-17 07:33:59 +00:00
extensions: ['.js'],
2016-05-31 14:36:52 +00:00
},
plugins: [
new webpack.DefinePlugin({
EMOJI_DATASOURCE_VERSION: `'${pack.devDependencies['emoji-datasource']}'`,
}),
],
2016-05-31 14:36:52 +00:00
bail: true,
}
if (!TEST) {
config.externals = config.externals.concat([
{
2017-10-07 04:02:02 +00:00
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
},
])
config.plugins = config.plugins.concat([
new BundleAnalyzerPlugin({ analyzerMode: 'static', openAnalyzer: false }),
])
}
module.exports = config