-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
104 lines (91 loc) · 2.61 KB
/
Copy pathwebpack.config.js
File metadata and controls
104 lines (91 loc) · 2.61 KB
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
var webpack = require('webpack');
var path = require('path');
var AssetsWebpackPlugin = require('assets-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var settings = {
destDir: '/dist/'
};
var isDevServer = path.basename(require.main.filename) === 'webpack-dev-server.js';
var ENV = process.env.npm_lifecycle_event;
var isTest = ENV === 'test' || ENV === 'test-watch';
settings.root = path.join(__dirname, path.dirname(settings.destDir));
var plugins = [];
if (!isTest) {
plugins.push(new ExtractTextPlugin("app.css"));
}
plugins.push(new AssetsWebpackPlugin());
plugins.push(new CleanWebpackPlugin([settings.destDir.split('/').slice(-2)[0]], {
root: settings.root,
versbose: true,
dry: false
}));
//do not minimize when using dev server
if (!isDevServer) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
}
}));
}
var preLoaders = [];
if (isTest) {
preLoaders.push({
test: /\.js$/,
exclude: [
/node_modules/,
/\.spec\.js$/
],
loader: 'isparta-loader'
})
}
/**
* Devtool
* Reference: http://webpack.github.io/docs/configuration.html#devtool
* Type of sourcemap to use per build type
*/
var devtool;
if (isTest) {
devtool = 'inline-source-map';
} else if (!isDevServer) {
devtool = 'source-map';
} else {
devtool = 'eval-source-map';
}
module.exports = {
cache: true,
context: __dirname,
entry: isTest ? {} : './src/app.js',
devtool: devtool,
output: isTest ? {} : {
filename: 'bundle.js',
path: path.join(__dirname, "dist"),
publicPath: "/dist/"
},
module: {
preLoaders: preLoaders,
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015']
}
}, {
test: /\.scss$/,
loader: isTest ? 'null' : ExtractTextPlugin.extract("style-loader", "css-loader?minimize!autoprefixer-loader!sass-loader")
}, {
test: /\.css$/,
loader: isTest ? 'null' : ExtractTextPlugin.extract("style-loader", "css-loader?minimize!autoprefixer-loader")
}, {
test: /\.(png|jpg|gif)$/,
loader: 'file-loader?name=images/[hash].[ext]'
}, {
test: /\.html$/,
include: /src/,
loader: 'ngtemplate?relativeTo=' + path.resolve(__dirname, './src') + '/!html'
}]
},
plugins: plugins
}