-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
105 lines (104 loc) · 3.45 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
const production = process.env.NODE_ENV === 'production';
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
module.exports = {
entry: {
app: path.resolve(__dirname, 'app/Resources/assets/js/app.js'),
vendor: [
'jquery',
'moment',
'highlightjs',
'bootstrap',
]
},
output: {
path: path.resolve(__dirname, 'web/builds'),
filename: production ? '[name].[hash].js' : '[name].js' ,
publicPath: '/builds/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: 'babel-loader'
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: { // CSS Nano configuration
minimize: {
discardComments: {
removeAll: true
},
core: true,
minifyFontValues: true
}
}
},
'sass-loader'
]
})
},
{
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
use: "url-loader"
},
{
test: /jquery/,
use: [
{ loader: 'expose-loader', options: '$' },
{ loader: 'expose-loader', options: 'jQuery' }
]
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
hljs: path.resolve(__dirname, 'app/Resources/assets/js/highlight.pack.js')
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new ExtractTextPlugin(production ? '[name].[hash].css' : '[name].css'),
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' }),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
compress: {
screw_ie8: true,
warnings: false
},
mangle: {
screw_ie8: true,
keep_fnames: true
},
comments: false
}),
new ManifestPlugin({
fileName: 'manifest.json',
basePath: 'builds/'
})
],
resolve: {
alias: {
fonts: path.resolve(__dirname, 'web/fonts'),
jquery: path.resolve(__dirname, 'app/Resources/assets/js/jquery-2.1.4.min.js'),
moment: path.resolve(__dirname, 'app/Resources/assets/js/moment.min.js'),
highlightjs: path.resolve(__dirname, 'app/Resources/assets/js/highlight.pack.js'),
bootstrap: path.resolve(__dirname, 'app/Resources/assets/js/bootstrap-3.3.4.min.js')
}
},
devtool: 'eval-cheap-module-source-map',
devServer: {
hot: true,
contentBase: './web/'
}
};