forked from Pylons/trypyramid.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dist.config.js
116 lines (112 loc) · 3.1 KB
/
webpack.dist.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
var path = require('path');
var webpack = require('webpack');
var WebpackNotifierPlugin = require('webpack-notifier');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var RobotsPlugin = require('@tanepiper/robots-webpack-plugin');
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
var node_modules_dir = path.resolve(__dirname, 'node_modules');
var img_dir = path.resolve(__dirname, 'src/img/');
var templates = require('./webpack.tmpl.config').templates;
var config = {
cache: true,
entry: {
app: path.resolve(__dirname, 'src/main.js'),
vendors: [
path.resolve(__dirname, 'src/vendors.js')
]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[hash].js'
},
resolve: {
root: path.resolve(__dirname, 'src'),
extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx'],
modulesDirectories: ['node_modules', 'src'],
alias: {}
},
module: {
loaders: [{
test: /\.(js|jsx)$/,
exclude: [node_modules_dir],
loaders: ['babel']
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?minimize')
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style',
'css!sass?includePaths[]=' + node_modules_dir
)
}, {
test: /\.(png|jpg|ico|gif|svg|pdf)$/,
exclude: [node_modules_dir],
loader: 'file?name=img/[name].[ext]'
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /\.txt$/,
loader: 'raw'
}, {
test: /\.ejs$/,
loader: 'ejs-compiled'
},{
test: /\.(woff|woff2|ttf|eot|svg)(\?.*)?$/,
exclude: [img_dir],
loader: 'file?name=fonts/[name].[ext]'
}, {
test: require.resolve('jquery'),
loader: 'expose?$!expose?jQuery'
}, {
test: /isotope\-|fizzy\-ui\-utils|desandro\-|masonry|outlayer|get\-size|doc\-ready|eventie|eventemitter/,
loader: 'imports?define=>false&this=>window'
}]
},
plugins: [
new RobotsPlugin(),
new WebpackNotifierPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
},
__DEBUG__: false
}),
new ExtractTextPlugin('[name].[hash].css', {
allChunks: true
}),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.[hash].js'),
new webpack.optimize.UglifyJsPlugin({
compress: true,
compressor: {
screw_ie8: true,
warnings: false
}
}),
new webpack.optimize.DedupePlugin(),
new StatsWriterPlugin({
path: path.join(__dirname, 'dist'),
filename: 'stats.json',
fields: ['hash', 'assetsByChunkName']
}),
new webpack.NoErrorsPlugin()
],
node: {
net: 'empty',
dns: 'empty'
}
};
if (templates) {
templates.forEach(function(template) {
template.mode = 'production';
config.plugins.push(new HtmlWebpackPlugin(template));
});
};
module.exports = config;