-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
106 lines (89 loc) · 2.49 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* global process */
var AutoPrefixer = require('autoprefixer');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var UnminifiedWebpackPlugin = require('unminified-webpack-plugin');
var Webpack = require('webpack');
var WebpackMerge = require('webpack-merge');
var Dotenv = require('dotenv-webpack');
var npm_target = process.env.npm_lifecycle_event;
var environment;
if (npm_target === 'start') {
environment = 'development';
} else {
environment = 'production';
}
var common = {
entry: {
app: './src/index.js'
},
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js', '.elm']
},
module: {
loaders: [{
test: /\.(eot|svg|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?/,
loader: 'file-loader'
}],
noParse: /^(?!.*Stylesheets).*\.elm$/
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new Webpack.optimize.CommonsChunkPlugin({
name: "init",
minChunks: Infinity
}),
new Webpack.optimize.OccurenceOrderPlugin(),
new Dotenv({
path: './.env',
safe: true
})
],
postcss: [AutoPrefixer({
browsers: ['last 2 versions']
})],
target: 'web'
};
if (environment === 'development') {
console.log('running development');
var devOnly = {
output: {
filename: '[name].js'
},
module: {
loaders: [
{
test: /src\/Stylesheets.elm$/,
loaders: [
'style-loader',
'css-loader',
'postcss-loader',
'elm-css-webpack-loader'
]
},
{
test: /\.elm$/,
exclude: [
/elm-stuff/,
/node_modules/,
/src\/Stylesheets.elm$/
],
loaders: [
'elm-hot-loader',
'elm-webpack-loader'
]
}
]
},
devServer: {
inline: true,
progress: true,
stats: 'errors-only'
}
};
module.exports = WebpackMerge(common, devOnly);
}