-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
117 lines (104 loc) · 4.26 KB
/
webpack.config.js
File metadata and controls
117 lines (104 loc) · 4.26 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
105
106
107
108
109
110
111
112
113
114
115
116
117
/// <reference path="typings/node/node.d.ts"/>
var path = require("path");
var webpackShared = require("./webpack.shared");
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var nodeModulesPath = path.join(__dirname, 'node_modules');
var config = {
// entry points - each will produce one bundled js file and one css file if there is any css in dependency tree
entry: {
vendors: [
'flux',
'react',
'react-dom',
'bluebird',
'jquery',
'bootstrap-js',
'bootstrap-css'
],
app: [
path.join(__dirname, 'js', 'Index.tsx')
]
},
// This is path to loaders
resolveLoader: {
root: nodeModulesPath
},
resolve: {
extensions: ['', '.tsx', '.ts', '.js', '.less', '.css'],
modulesDirectories: ["node_modules", "resources"],
alias: {
'react': path.join(nodeModulesPath, 'react', 'react.js'),
'react-dom': path.join(nodeModulesPath, 'react-dom', 'dist', 'react-dom.js'),
'bluebird': path.join(nodeModulesPath, 'bluebird', 'js', 'browser', 'bluebird.min.js'),
'flux': path.join(nodeModulesPath, 'flux', 'index.js'),
'jquery': path.join(nodeModulesPath, 'jquery', 'dist', 'jquery.js'),
'bootstrap-js': path.join(nodeModulesPath, 'bootstrap', 'dist', 'js', 'bootstrap.min.js'),
'bootstrap-css': path.join(nodeModulesPath, 'bootstrap', 'dist', 'css', 'bootstrap.min.css'),
'RoboCoachConfig': path.join(__dirname, 'js', 'RoboCoachConfig.prod.json')
}
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
preLoaders: [
{ test: /\.ts(x?)$/, loader: "tslint", include: path.resolve(__dirname, "js") },
],
noParse: [],
loaders: [
{ test: /\.ts(x?)$/, loader: path.join(__dirname, 'ts-loader?instance=jsx'), include: path.resolve(__dirname, "js") },
{ test: /\.rt\.html/, loader: "react-templates-loader?targetVersion=0.14.0" /*path.join(__dirname, "rt-loader!ts-loader")*/ },
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader?minimize") },
{ test: /\.less$/, exclude: /\.module\.less$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader?minimize!less-loader?compress"), include: path.resolve(__dirname, "js") },
{ test: /\.module\.less$/,
loader: ExtractTextPlugin.extract("style-loader","css-loader?minimize&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!less-loader?-compress"),
include: path.resolve(__dirname, "js") },
{ test: /\.(jpg|png|woff|eot|ttf|svg|gif|mp3|mp4|ogv)$/, loader: "file-loader?name=[name]_[hash].[ext]", include: path.resolve(__dirname, "js") },
{ test: /\.json/, loader: "json-loader" },
// for bootstrap-webpack
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
]
},
plugins: [
new CleanWebpackPlugin(['dist']),
new ExtractTextPlugin('[name].css', { allChunks: true }),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new HtmlWebpackPlugin({
template: "index.html",
hash: true
}),
function() {
this.plugin("done", function(stats) {
if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf('--watch') == -1) {
console.log("================> Errors count: ", stats.compilation.errors.length);
console.log("================> Errors: ", stats.compilation.errors);
process.exit(1);
}
});
}
],
tslint: {
// Rules are in tslint.json
emitErrors: true, // false = WARNING for webpack, true = ERROR for webpack
formattersDirectory: path.join(nodeModulesPath, 'tslint-loader', 'formatters')
},
};
if (webpackShared.isProduction) {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
config.plugins.push(new webpack.DefinePlugin({
'process.env': {NODE_ENV: '"production"'}
}));
}
module.exports = config;