forked from tzachsharabi/material-ui-scrollable-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
91 lines (87 loc) · 2.27 KB
/
webpack.config.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
const combineLoaders = require('webpack-combine-loaders');
const dotenv = require('dotenv');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV;
// import .env variables to global space
const dotEnvVars = dotenv.config();
const dotEnvDefines = !dotEnvVars.error ? dotEnvVars.parsed : {};
const defines = Object.keys(dotEnvDefines).reduce((accumulator, key) => {
const retAccumulator = accumulator;
const val = JSON.stringify(dotEnvDefines[key]);
retAccumulator[`__${key.toUpperCase()}__`] = val;
return retAccumulator;
}, {
'process.env': {
NODE_ENV: JSON.stringify(NODE_ENV),
},
});
const config = {
entry: [
'react-hot-loader/patch',
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'src', 'index.js'),
],
output: {
filename: 'app.js',
publicPath: '/',
},
devtool: 'source-map',
devServer: {
inline: true,
historyApiFallback: true,
hot: true,
port: 3000,
},
module: {
loaders: [{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
loaders: ['babel-loader'],
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: combineLoaders([{
loader: 'css-loader',
query: {
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]',
},
}]),
}),
}],
},
plugins: [
new webpack.DefinePlugin(defines),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, 'src', 'www', 'index.html'),
}),
new webpack.LoaderOptionsPlugin({
options: {
},
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('styles.css'),
new webpack.HotModuleReplacementPlugin(),
],
resolve: {
modules: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules'),
'node_modules',
],
extensions: [
'.js',
'.jsx',
],
alias: {
'material-ui-scrollable-tabs': path.resolve(__dirname, '../src'),
},
},
};
module.exports = config;