/
webpack.config.js
60 lines (55 loc) · 1.96 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
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
var outputFilename = '[name].js';
const rootPaths = [
path.join(__dirname, './bower_components'),
path.join(__dirname, './app/css'),
path.join(__dirname, './app/image'),
];
var plugins = [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './app/index.html'
})
];
if (process.env.COMPRESS) {
plugins.push(
new ExtractTextPlugin('[name].[contenthash:6].css')
);
outputFilename = '[name].[chunkhash:6].js';
} else {
plugins.push(
new ExtractTextPlugin('[name].css')
);
}
module.exports = {
entry: {
vendor: './app/vendor',
main: './app/app.js'
},
output: {
path: './dist',
publicPath: './',
filename: outputFilename
},
resolve: {
root: rootPaths
},
module: {
preLoaders: [
{ test: /\.js$/, exclude: /node_modules|bower_components/, loader: 'eslint-loader' }
],
loaders: [
{ test: /\.js$/, exclude: /node_modules|bower_components/, loader: 'babel!ng-annotate?add=true' },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css') },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css!sass') },
{ test: /\.html$/, loader: 'ngtemplate?relativeTo=' + path.resolve(__dirname) + '!html' },
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?(\?t=\d{10})?$/, loader: 'url-loader?limit=10000&minetype=application/font-woff&name=[path][name].[hash:6].[ext]' },
{ test: /\.jpe?g$|\.gif$|\.png$/, loader: 'url-loader?limit=10000&name=images/[name].[hash:6].[ext]' },
{ test: /\.(ttf|svg|eot)(\?v=[0-9]\.[0-9]\.[0-9])?(\?t=\d{10})?$/, loader: 'file-loader?name=[path][name].[hash:6].[ext]' }
]
},
plugins: plugins
};