-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
105 lines (99 loc) · 3.29 KB
/
webpack.config.js
File metadata and controls
105 lines (99 loc) · 3.29 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
94
95
96
97
98
99
100
101
102
103
104
105
'use strict';
var path = require('path');
var webpack = require('webpack');
var statsBuilder = require('./config/stats-builder');
// 1. Debug [bd604d99e75e45d38bc7ac8fc714cde0097d901f]
// 2. DevTool [3baaa97f47149759b6623684baf7dd794a708f3a]
// 3. Target [61ad50a9b9189cc3cf1874568e35e7901ff4c982]
// 4. Entry [19172e9e47fee4109f3d1d86c3076acdc36822f2]
// 5. Output [4bed336194a9a5c86b6a734f03b3570d2aae1a68]
// 6. Resolve [ac7f958cc028becfb4b2bec9c474bd2d5e8b6095]
// 7. Module [b8ff02892916ff59f7fbd4e617fccd01f6bca576]
module.exports = function(options) {
// Stylesheets loaders
var browsers = {
browsers: [
'last 2 version',
'ie >= 10'
]
};
var stylesheetLoaders = {
'css': 'css-loader!autoprefixer-loader?' + JSON.stringify(browsers)
};
// Resolve config
var modulesDirectories = ['node_modules'];
var aliases = {};
var aliasLoader = {};
// Output config
var publicPath = options.devServer ? 'http://localhost:8090/application/' : '/application/';
var output = {
path: path.resolve(__dirname, 'application'),
publicPath: publicPath,
filename: '[name].js' + (options.longTermCaching ? '?[chunkhash]' : ''),
chunkFilename: (options.devServer ? '[id].js' : '[name].js') + (options.longTermCaching ? '?[chunkhash]' : ''),
sourceMapFilename: 'debugging/[file].map',
pathinfo: options.debug
};
console.log(output);
// JS Plugings
var scriptLoaders = {
'jsx': options.hotComponents ? ['react-hot-loader', 'babel-loader'] : ['babel-loader'],
'js': {
loader: 'babel-loader',
include: path.join(__dirname, 'assets')
}
};
var excludeFromStats = [];
var plugins = [
function() {
this.plugin('done', statsBuilder(excludeFromStats, publicPath));
},
new webpack.PrefetchPlugin('react')
];
// Optimize settings for JS
if (options.optimize) {
plugins.push(
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production') }}),
new webpack.NoErrorsPlugin()
);
}
return {
debug: true, // [bd604d99e75e45d38bc7ac8fc714cde0097d901f]
devtool: 'source-map', // [3baaa97f47149759b6623684baf7dd794a708f3a]
target: 'web', // [61ad50a9b9189cc3cf1874568e35e7901ff4c982]
entry: { // [19172e9e47fee4109f3d1d86c3076acdc36822f2]
application: 'assets/index.js'
// application: path.join(__dirname, 'assets/scripts/main.js')
},
output: output, // [4bed336194a9a5c86b6a734f03b3570d2aae1a68]
resolveLoader: {
root: path.join(__dirname, 'node_modules'),
alias: aliasLoader
},
resolve: { // [ac7f958cc028becfb4b2bec9c474bd2d5e8b6095]
root: __dirname,
modulesDirectories: modulesDirectories,
alias: aliases
},
module: { // [b8ff02892916ff59f7fbd4e617fccd01f6bca576]
loaders: [{
test: /\.js$/,
include: path.join(__dirname, 'assets'),
exclude: /node_modules/,
loader: 'babel'
}]
},
devServer: {
contentBase: __dirname,
quiet: false,
noInfo: false,
publicPath: "/application/",
stats: {
colors: true,
exclude: excludeFromStats
}
}
};
};