-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.release.js
111 lines (110 loc) · 3.05 KB
/
webpack.release.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var path = require('path')
var webpack = require('webpack')
var startYear = 2016
var currentYear = new Date().getFullYear()
var version = process.env.VERSION || 'latest'
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
mode: 'production',
optimization: {
minimizer: [
new UglifyJSPlugin({
uglifyOptions: {
/**
* Safari bug: Cannot declare a const twice
*/
safari10: true
}
})
]
},
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: `olasearch.core.${version}.js`,
library: 'OlaSearch',
libraryTarget: 'umd'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.LoaderOptionsPlugin({
minimize: true
}),
// new UglifyJsPlugin({
// sourceMap: true,
// uglifyOptions: {
// ie8: false,
// output: {
// comments: false,
// beautify: false,
// }
// }
// }),
new webpack.BannerPlugin({ banner: `Copyright Ola Search Pte Ltd ${startYear} - ${currentYear}`, raw: false, entryOnly: true })
],
resolve: {
alias: {
// 'olasearch': path.join(__dirname, './../npm-olasearch'),
// 'react': path.join(__dirname, './node_modules/react'),
// 'react-dom': path.join(__dirname, './node_modules/react-dom'),
// 'prop-types': path.join(__dirname, './node_modules/prop-types'),
// 'create-react-class': path.join(__dirname, './node_modules/create-react-class'),
// 'object-assign': path.join(__dirname, './node_modules/object-assign'),
// 'fbjs': path.join(__dirname, './node_modules/fbjs'),
// 'react-redux': path.join(__dirname, './node_modules/react-redux'),
// 'redux': path.join(__dirname, './node_modules/redux'),
// '@olasearch/icons': path.resolve(__dirname, './../ola-icons'),
// 'styled-jsx': path.join(__dirname, './../../styled-jsx/src')
},
modules: [
'node_modules', path.resolve(__dirname, './node_modules')
]
},
module: {
rules: [{
test: /\.js?/,
use: {
loader: 'babel-loader'
},
exclude: /node_modules/,
include: [
path.join(__dirname, './'),
path.join(__dirname, './src'),
// path.join(__dirname, './../../styled-jsx/src'),
// path.resolve(__dirname, 'node_modules', 'rambda')
]
},
{ test: require.resolve('react'), loader: 'expose-loader?React' },
{ test: require.resolve('react-dom'), loader: 'expose-loader?ReactDOM' },
{
test: /redux\/es\/index.js/,
use: [
{
loader: 'expose-loader',
options: 'Redux'
}
]
},
{
test: /react-redux\/es\/index.js/,
use: [
{
loader: 'expose-loader',
options: 'ReactRedux'
}
]
}
]
},
externals: {
'moment': 'moment'
}
}