-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
93 lines (90 loc) · 2.5 KB
/
webpack.prod.js
File metadata and controls
93 lines (90 loc) · 2.5 KB
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
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var Clean = require('webpack-cleanup-plugin');
var parseArgs = require('minimist');
var Argv = parseArgs(process.argv);
var Dependencies = require(Argv.srcDirectory + '/../package.json').dependencies;
var modulesPaths = [Argv.srcDirectory];
try {
fs.lstatSync(Argv.srcDirectory + '/common');
modulesPaths.push(fs.realpathSync(Argv.srcDirectory + '/common'));
} catch (error) {
console.info('No code symlink ... skipping');
}
module.exports = {
entry: {
'app': Argv.entryPoint,
'vendors': Object.keys(Dependencies)
},
output: {
publicPath: '/',
path: path.resolve(Argv.srcDirectory + '/../', 'dist'),
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js'
},
resolve: {
fallback: path.join(process.cwd(), 'node_modules')
},
resolveLoader: {
root: path.resolve(__dirname, 'node_modules')
},
module: {
loaders: [
{
test: /\.woff$/,
loader: 'url?limit=100000',
include: modulesPaths
},
{
test: /\.less$/,
loader: 'style!css!less',
include: modulesPaths
},
{
test: /\.jsx?/,
loader: 'babel-loader',
query: {
presets: [
require.resolve('babel-preset-es2015'),
require.resolve('babel-preset-react'),
require.resolve('babel-preset-stage-0')
]
},
include: modulesPaths
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
],
include: modulesPaths
}
]
},
plugins: [
new Clean(),
new webpack.DefinePlugin({
__DEV__ : false,
__VERSION__ : JSON.stringify(require(Argv.srcDirectory + '/../package.json').version),
'process.env.NODE_ENV': JSON.stringify('production')
}),
new ExtractTextPlugin('[name].[chunkhash].css'),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new HtmlWebpackPlugin({
title: 'λ Lambda Dev Server',
template: path.join(Argv.srcDirectory, '/index.tpl.html')
})
]
};