This repository has been archived by the owner on Feb 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
108 lines (90 loc) · 2.51 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
106
107
108
'use strict';
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
// Detect if we're running webpack dev server or building a distribution.
var devServer = path.basename(require.main.filename) === 'webpack-dev-server.js';
var config = {
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new ExtractTextPlugin('styles.css'),
new webpack.ProvidePlugin({'window.jQuery': 'jquery'})
],
entry: './scripts/init.coffee',
output: {
filename: 'main.js',
path: 'dist/'
},
resolve: {
extensions: ['', '.js', '.coffee'],
alias: {
handlebars: 'handlebars/dist/handlebars'
}
},
amd: {
jQuery: true
},
externals: {
config: 'AULE_CONFIG'
},
module: {
preLoaders: [{
test: /\.coffee$/,
exclude: /node_modules/,
loader: 'coffeelint-loader'
}],
loaders: [{
test: /\.coffee$/,
loader: 'coffee-loader'
}, {
test: /\.hb$/,
loader: 'handlebars-loader?extensions=.hb&helperDirs[]=' + __dirname + '/templates/helpers'
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader')
}, {
test: /\.png$/,
loader: 'url-loader?limit=10000&minetype=image/png'
}, {
test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff'
}, {
test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff2'
}, {
test: /\.(otf|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}]
},
cache: false,
debug: false,
devtool: false
};
if (devServer) {
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({'process.env.NODE_ENV': '"development"'})
);
config.entry = [
'webpack/hot/only-dev-server',
'./scripts/init.coffee'
];
config.devServer = {
hot: true,
historyApiFallback: true
},
config.output.publicPath = '/dist/';
config.cache = true;
config.debug = true;
config.devtool = 'eval';
} else {
config.plugins.push(
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({compress: {drop_console: false}}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.DefinePlugin({'process.env.NODE_ENV': '"production"'})
);
}
module.exports = config;