-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
122 lines (120 loc) · 3.3 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const BowerWebpackPlugin = require('bower-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PATHS = {
app: path.join(__dirname, 'app'),
build: path.join(__dirname, 'www'),
};
const PRIVATE_MODULES = [
path.resolve(__dirname, 'app')
];
module.exports = {
historyApiFallback: true,
entry: {
app: [
PATHS.app
],
vendor: ['angular', 'ionic/release/js/ionic.js', 'ionic/release/js/ionic-angular.js', 'angular-sanitize', 'angular-animate', 'angular-ui-router', 'angular-aria', 'ngstorage', 'angular-messages', 'angular-translate', 'angular-translate-loader-partial']
},
output: {
path: PATHS.build,
filename: '[name].[chunkhash].js',
chunkFilename: '[chunkhash].js',
hash: true
},
resolve: {
root: [
path.join(__dirname, 'app'),
path.join(__dirname, 'bower_components'),
path.join(__dirname, 'node_modules')
],
moduleDirectories: [
path.resolve('./bower_components'),
path.resolve('./node_modules')
],
alias: {
app: [path.join(__dirname, 'app')]
}
},
module: {
preLoaders: [{
test: /\.js$/,
loaders: ['eslint'],
include: /app/
}],
loaders: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader')
}, {
test: /\.js$/,
loaders: ['ng-annotate', 'babel?cacheDirectory&presets[]=react,presets[]=es2015,presets[]=stage-1'],
include: PRIVATE_MODULES
}, {
test: /\.html$/,
loader: 'ngtemplate?relativeTo=components/',
exclude: /Lazy/,
include: /components/
}, {
test: /\.html$/,
loader: 'html',
include: /components/
}, {
test: /\.woff/,
loader: 'url?limit=10000&mimetype=application/font-woff&name=fonts/[name].[ext]'
}, {
test: /\.ttf/,
loader: 'file?name=fonts/[name].[ext]'
}, {
test: /\.eot/,
loader: 'file?name=fonts/[name].[ext]'
}, {
test: /fonts[\/\\].*\.svg/,
loader: 'file?name=fonts/[name].[ext]'
}, {
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=images/[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
}, {
test: /\.json/,
loader: 'file?name=locale/[path][name].[ext]',
include: /locale/
}, {
test: /[\/\\]angular\.js$/,
loader: 'exports?angular'
}, {
test: /[\/\\]ionic\.js$/,
loader: 'exports?ionic'
}]
},
plugins: [
new webpack.ProvidePlugin({
_: 'lodash'
}),
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(
'package.json', true
)
),
new BowerWebpackPlugin({
searchResolveModulesDirectories: false
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
}),
new HtmlWebpackPlugin({
title: 'todo',
template: './app/index.html',
inject: 'body'
}),
new ExtractTextPlugin('[name].[contenthash].css'),
new webpack.NoErrorsPlugin()
]
};