forked from aleksandarbusjovic/react-dates-presets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
131 lines (119 loc) · 4.02 KB
/
webpack.config.js
File metadata and controls
131 lines (119 loc) · 4.02 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const discardComments = require('postcss-discard-comments');
const resType = require('postcss-responsive-type');
const flexbugsFixes = require('postcss-flexbugs-fixes');
const nested = require('postcss-nested');
const autoprefixer = require('autoprefixer');
const reporter = require('postcss-reporter');
module.exports = [
{
name: 'build',
context: __dirname,
entry: path.resolve(__dirname, './src/DatePresetPicker.js'),
output: {
path: path.join(__dirname, 'lib'),
filename: 'index.js',
publicPath: '/lib/',
library: 'react-dates-presets',
libraryTarget: 'commonjs2',
},
module: {
loaders: [
{ test: /\.js?$/, loader: 'babel', include: path.join(__dirname, 'src') },
{ test: /\.css$/, exclude: [/node_modules/], loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[local]-[hash:base64:5]!postcss') },
{ test: /\.css$/, include: [/node_modules/], loader: ExtractTextPlugin.extract('style', 'css') },
],
},
externals: {
react: 'react',
'react-dates': 'react-dates',
'react-dom': 'react-dom',
},
target: 'web',
postcss: [
// responsive type
resType(),
// Discard comments in your CSS files with PostCSS.
// https://github.com/ben-eb/postcss-discard-comments
// Remove all comments... we don't need them further down the line
// which improves performance (reduces number of AST nodes)
discardComments({
removeAll: true,
}),
// Tries to fix all of flexbug's issues
// https://github.com/luisrudge/postcss-flexbugs-fixes
flexbugsFixes,
// Unwrap nested rules like how Sass does it.
// https://github.com/postcss/postcss-nested
nested,
autoprefixer({ browsers: ['last 2 versions'] }),
// Log PostCSS messages to the console
reporter({
clearMessages: true,
}),
],
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new ExtractTextPlugin('styles.css'),
],
},
{
name: 'demo',
entry: {
app: path.resolve(__dirname, 'demo/App.jsx'),
vendor: ['react', 'react-dates', 'react-dom'],
},
output: {
path: path.join(__dirname, 'demo'),
filename: 'app.js',
},
module: {
loaders: [
{ test: /\.jsx$/, loader: 'babel', include: path.join(__dirname, 'demo') },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css') },
],
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
target: 'web',
postcss: [
// responsive type
resType(),
// Discard comments in your CSS files with PostCSS.
// https://github.com/ben-eb/postcss-discard-comments
// Remove all comments... we don't need them further down the line
// which improves performance (reduces number of AST nodes)
discardComments({
removeAll: true,
}),
// Tries to fix all of flexbug's issues
// https://github.com/luisrudge/postcss-flexbugs-fixes
flexbugsFixes,
// Unwrap nested rules like how Sass does it.
// https://github.com/postcss/postcss-nested
nested,
autoprefixer({ browsers: ['last 2 versions'] }),
// Log PostCSS messages to the console
reporter({
clearMessages: true,
}),
],
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new ExtractTextPlugin('styles.css'),
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */'vendor', /* filename= */'vendor.js'),
new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } }),
],
},
];