This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
107 lines (95 loc) · 3.34 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
var _ = require( 'lodash' );
var path = require( 'path' );
var webpack = require( 'webpack' );
var HtmlWebpackPlugin = require( 'html-webpack-plugin' );
var pathApp;
function pathTo() {
return path.join( __dirname, 'src', path.join.apply( path, arguments ) );
}
pathApp = _.partial( pathTo, 'app' );
module.exports = function ( options ) {
var config = _.merge( {}, {
entry: {
vendor: [
'font-awesome/css/font-awesome.min.css',
'bootstrap/dist/css/bootstrap.min.css',
'bootstrap/dist/css/bootstrap-theme.min.css',
'jquery',
'bluebird',
'lodash',
'angular',
'angular-animate',
'angular-aria',
'angular-ui-router',
'angular-strap/dist/angular-strap.min.js',
'angular-strap/dist/angular-strap.tpl.min.js'
]
},
output: {
path: path.join( __dirname, 'build' ),
filename: 'js/[name]-[hash].js',
publicPath: '/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.ProvidePlugin( {
jQuery: 'jquery',
$: 'jquery',
'window.jQuery': 'jquery'
} ),
new HtmlWebpackPlugin( {
template: './src/assets/index.html',
inject: 'body'
} ),
new webpack.optimize.CommonsChunkPlugin( 'vendor', 'js/vendor-[hash].js' )
],
resolve: {
extensions: [ '', '.js' ],
alias: {
//app sub aliases
app: pathApp( 'index.js' ),
controllers: pathApp( 'controllers' ),
directives: pathApp( 'directives' ),
//assets sub aliases
assets: pathTo( 'assets' ),
//vendor aliases
jquery: 'jquery/dist/jquery.min.js'
}
},
module: {
loaders: [
{
test: /\.html$/,
loader: 'ngtemplate?relativeTo=' + (path.resolve(__dirname, './src/app')) + '/!html'
},
{
test: /\.styl$/,
loader: 'style-loader!css!stylus'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?name=assets/[hash][name].[ext]&limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader?name=assets/[hash][name].[ext]'
},
{
test: /\.jpg|\.png|\.mp3/,
loader: 'file-loader?name=assets/[hash][name].[ext]'
}
]
},
resolveLoader: {
root: path.join( __dirname, 'node_modules' )
}
}, options.overrides );
config.module.loaders = _.union( config.module.loaders, options.loaders );
config.plugins = _.union( config.plugins, options.plugins );
return config;
};