-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
98 lines (92 loc) · 2.37 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
'use strict';
var webpack = require('webpack');
var path = require('path');
var autoprefixer = require('autoprefixer');
var APP = path.join(__dirname + '/src');
// http://webpack.github.io/docs/stylesheets.html
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var config = {
context: APP, // set the `app` directory as the context
entry: {
app: ['webpack/hot/dev-server', './app/app.js'],
vendors: ['angular', 'angular-new-router', './app/vendors.js']
},
// output is for DEVELOPMENT
output: {
path: path.join(__dirname, 'dist/'),
//publicPath: '/public/',
filename: '[name].js' // based on the entry point key name
},
module: {
loaders: [
{
test: /\.less$/,
loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader!postcss-loader!less-loader'
),
exclude: /node_modules/
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader!postcss-loader'
)
},
{
test: /\.js$/,
loader: 'ng-annotate!babel',
exclude: /node_modules|bower_components/
},
{
test: /\.(woff|woff2|ttf|eot|svg)(\?]?.*)?$/,
loader: 'url-loader?name=res/[name].[ext]?[hash]'
},
{
test: /\.html/,
loader: 'raw'
},
{
test: /\.json/,
loader: 'json'
}
]
},
postcss: function () {
return {
defaults: [autoprefixer],
cleaner: [autoprefixer({ browsers:["last 15 version"], cascade: true })]
};
},
resolve: {
root: APP
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
MODE: {
production: process.env.NODE_ENV === 'production'
}
}),
new ExtractTextPlugin('[name].css')
],
// you can now require('file') instead of require('file.js')
extensions: ['', '.js', '.json', '.html'],
// `eval` to see the generated code (DEV only) (see Console Sources tab)
// `eval-source-map` the exact code (DEV only)
// `source-map` generates source map files (for PRODUCTION)
devtool: 'eval-source-map'
};
/////////////////////////////////////////////
// PRODUCTION
/////////////////////////////////////////////
if (process.env.NODE_ENV === 'production') {
// Change destination folder for Production code
config.output.path = __dirname + '/dist';
// Uglify JS
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
// Generate Source map files
config.devtool = 'source-map';
}
module.exports = config;