forked from AMar4enko/ionic-webpack-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
112 lines (106 loc) · 3.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
109
110
111
112
var _ = require("lodash");
var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var argv = require('yargs').argv;
var cssLoaders, plugins;
var appRoot = path.resolve(__dirname, "./app");
argv.env = argv.env || 'development';
if(argv.env != 'development'){
cssLoaders = [
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader?root="+appRoot) },
{ test: /\.less$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader?root="+appRoot+"!less-loader") },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract("style-loader","css-loader?root="+appRoot+"!sass") }
];
plugins = [
new ExtractTextPlugin("[name].css")
];
}else{
cssLoaders = [
{ test: /\.css$/, loader: "style-loader!css-loader?root="+appRoot },
{ test: /\.less$/, loader: "style-loader!css-loader?root="+appRoot+"!less-loader" },
{ test: /\.scss$/, loader: "style-loader!css-loader?root="+appRoot+"!sass" }
];
plugins = [];
}
module.exports = {
cache: true,
debug: true,
devTool: 'eval',
entry: {
vendor: ['angular', 'angular-ui-router', 'lodash', 'angular-animate', 'angular-cache', 'angular-sanitize', 'js-data', 'js-data-angular'],
app: ['./app/index']
},
output: {
path: path.join(__dirname, "www"),
filename: "[name].bundle.js",
chunkFilename: "[id].bundle.js"
},
module: {
loaders: cssLoaders.concat([
{ test: /\.(jpe?g|png|gif)$/i, loader: 'image?bypassOnDebug&optimizationLevel=7&interlaced=false' },
{
test : /\.json$/,
loader : 'json'
},
{ test: /\.html$/,
loader: "ngtemplate?relativeTo=" + (path.resolve(__dirname, './app')) + "/&module=templates!html?root=app"},
{ test: /\.jade$/,
loader: "ngtemplate?relativeTo=" + (path.resolve(__dirname, './app')) + "/&module=templates!html!jade-html"},
{ test: /\.woff($|\?)/, loader: 'url-loader?prefix=font/&limit=5000&mimetype=application/font-woff' },
{ test: /\.woff2($|\?)/, loader: 'url-loader?prefix=font/&limit=5000&mimetype=application/font-woff' },
{ test: /\.ttf($|\?)/, loader: "file-loader?prefix=font/" },
{ test: /\.eot($|\?)/, loader: "file-loader?prefix=font/" },
{ test: /\.svg($|\?)/, loader: "file-loader?prefix=font/" },
{
test : /[\/]angular\.js$/,
loader : 'exports?angular'
}, {
test : /[\/]ionic\.js$/,
loader : 'exports?ionic'
}
]),
noParse: [
/bower_components/
]
},
resolve: {
root: [
path.join(__dirname, 'app'),
path.join(__dirname, 'bower_components'),
path.join(__dirname, 'node_modules')
],
moduleDirectories: [
'bower_components',
'node_modules'
],
alias: {
app: [path.join(__dirname, 'app')]
}
},
externals: {
'js-data-schema': 'undefined'
},
plugins: plugins.concat([
new webpack.ProvidePlugin({
_: "lodash"
}),
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(
'bower.json', ['main'])
),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(argv.env || 'development')
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
}),
new HtmlWebpackPlugin({
pkg : require('./package.json'),
template : 'app/index.html',
env : argv.env || 'development'
})
])
};