-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
74 lines (68 loc) · 2.04 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
const webpack = require('webpack');
// Used for external CSS file
const ExtractTextPlugin = require('extract-text-webpack-plugin');
// Used to call custom shell commands before/after build
const WebpackShellPlugin = require('webpack-shell-plugin');
// .env.development.production.example
const Dotenv = require('dotenv-webpack');
module.exports = {
// Include entry file(s)
entry: ['./app/app.es6'],
// Output file
output: {
filename: 'app.js',
path: __dirname + '/public'
},
module: {
// Loaders
rules: [
// SCSS
{
test: /\.scss$/,
//loaders: ['style', 'css', 'sass'] // inline
loader: ExtractTextPlugin.extract('css-loader!sass-loader') // external file
},
// ES6 files
{
test: /\.es6$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
// JSHint
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'jshint-loader'
}
]
},
plugins: [
// Export CSS to external file
new ExtractTextPlugin({ filename: 'app.css', disable: false, allChunks: true }),
// Execute commands before and after build
new WebpackShellPlugin({
onBuildStart:['echo "\033[1;33mWebpack Start\033[0m"'],
onBuildEnd:['echo "\033[1;32mWebpack End\033[0m"'],
onBuildExit:['echo "\033[1;37mWebpack Exit\033[0m"']
}),
new Dotenv({
path: '.env.development'
}),
// inject ES5 modules as global vars
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Tether: 'tether'
})
],
// Resolve file extensions
resolve: {
extensions: ['.js', '.es6']
},
// Watch dev server
watch: true
};