forked from freeCodeCampLondon/FCCLND
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
94 lines (89 loc) · 2.2 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
var NODE_ENV = process.env.NODE_ENV || 'development';
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var isDev = NODE_ENV === 'development';
var isProd = NODE_ENV === 'production';
var config = {
context: __dirname + '/dev/app',
entry: [
'./app.js'
],
output: {
path: __dirname + '/dist',
filename: 'bundle.js'
},
resolve: {
alias: {
/* Fixes a problem with isotope dependency resolution */
'masonry': 'masonry-layout',
'isotope': 'isotope-layout'
}
},
module: {
preLoaders: [
{ /* Lint JavaScript */
test: /\.jsx?$/,
include: /dev/,
loader: 'eslint'
}
],
loaders: [
{ /* Angular HTML Templates */
test: /\.html$/,
loader: 'raw'
},
{ /* Compile Sass and extract as separate file */
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')
},
{ /* WOFF Fonts */
test: /\.(woff|woff2)(\?[\s\S]+)?$/,
loader: 'url?mimetype=application/font-woff&name=assets/fonts/[name].[hash].[ext]'
},
{ /* TTF, EOT & SVG Fonts */
test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/,
loader: 'file?name=assets/fonts/[name].[hash].[ext]'
}
]
},
postcss: function() {
return [require('autoprefixer')({})];
},
plugins: [
new HtmlWebpackPlugin({
template: __dirname + '/dev/app/index.html',
filename: 'index.html',
inject: 'body'
}),
new ExtractTextPlugin('main.css'),
new CopyWebpackPlugin([
{
from: 'data/fccLndData.json',
to: 'data'
},
{
from: 'assets/images',
to: 'assets/images'
}
]),
new CleanWebpackPlugin(['dist'])
]
};
/**
* Production Config Options
*/
if(isProd) {
/* Work from Firebase in Production */
config.module.loaders.push({
test: /app.config\.js$/,
loader: 'string-replace',
query: {
search: 'true',
replace: 'false'
}
});
}
module.exports = config;