-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
143 lines (125 loc) · 3.6 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
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
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Webpack
*
* @usage
* ./node_modules/webpack/bin/webpack.js --progress --profile --json > stats.json
*
* @see https://github.com/rossta/rossta.github.com
*/
const Webpack = require('webpack')
const Clean = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const Path = require('path')
const Fs = require('fs')
const extractSass = new ExtractTextPlugin({
filename: 'assets/stylesheets/all.bundle.css',
// disable: process.env.NODE_ENV === 'development',
allChunks: true
})
// Exports
module.exports = {
cache: true,
entry: {
body: [
Path.join(__dirname, '/source/assets/javascripts/_body.js')
]
},
resolve: {
alias: {
// Assets
js: Path.join(__dirname, '/source/assets/javascripts'),
css: Path.join(__dirname, '/source/assets/stylesheets'),
source: Path.join(__dirname, '/source/modules'),
// Partials
atom: Path.join(__dirname, '/source/partials/atom'),
molecule: Path.join(__dirname, '/source/partials/molecule'),
organism: Path.join(__dirname, '/source/partials/organism'),
social: Path.join(__dirname, '/source/partials/social'),
template: Path.join(__dirname, '/source/partials/template')
}
},
output: {
path: Path.join(__dirname, '/.tmp'),
filename: 'assets/javascripts/[name].bundle.js'
},
module: {
rules: [
// Babel
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
include: [
Path.resolve(__dirname, 'source/modules/search')
],
use: {
loader: 'babel-loader',
options: {
presets: [
['env', {
'targets': {
'browsers': ['last 2 versions']
},
'debug': false
}]
]
}
}
},
// Coffee
{
test: /\.coffee$/,
exclude: /(node_modules|bower_components)/,
include: [
Path.resolve(__dirname, 'source/assets/javascripts/_lib'),
Path.resolve(__dirname, 'source/modules/admin'),
Path.resolve(__dirname, 'source/modules/blog'),
Path.resolve(__dirname, 'source/modules/corporate-competition'),
Path.resolve(__dirname, 'source/modules/goldcard'),
Path.resolve(__dirname, 'source/modules/heineken'),
Path.resolve(__dirname, 'source/modules/olapic'),
Path.resolve(__dirname, 'source/partials/atom'),
Path.resolve(__dirname, 'source/partials/social')
],
use: ['coffee-loader']
},
// SCSS
// @see https://github.com/webpack-contrib/sass-loader
// @see http://eng.localytics.com/faster-sass-builds-with-webpack/
{
test: /\.scss$/,
exclude: /(node_modules|bower_components)/,
include: [
Path.resolve(__dirname, 'source/assets/stylesheets')
],
use: extractSass.extract({
use: [{
loader: 'css-loader'
},
{
loader: 'sass-loader'
}],
// use style-loader in development
fallback: 'style-loader'
})
},
// Fonts
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
exclude: /(bower_components)/,
include: [
Path.resolve(__dirname, 'node_modules/font-awesome/fonts')
],
use: 'file-loader?name=/assets/fonts/[name].[ext]'
}
]
},
plugins: [
new Clean(['.tmp']),
extractSass,
new Webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
]
}