-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
74 lines (71 loc) · 3.14 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
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const OptimizeJsPlugin = require("optimize-js-plugin");
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const srcDir = 'public_src';
const outputDir = 'public';
module.exports = {
devtool: "source-map",
entry: {
app: path.resolve(srcDir, 'bootstrap.ts')
},
output: {
path: path.resolve(__dirname, outputDir),
filename: '[name].[hash].bundle.js',
sourceMapFilename: '[name].[hash].map',
chunkFilename: '[id].[hash].chunk.js'
},
resolve: {
extensions: ['.ts', '.component.ts', '.service.ts', '.js', '.component.html', '.component.less', '.less', '.css'],
alias: {
'webworkify': 'webworkify-webpack',
'mapbox-gl': path.resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js')
}
},
module: {
rules: [
{ test: /\.ts$/, enforce: 'pre', loader: 'tslint-loader' },
{ test: /(\.component|\.service|)\.ts$/, use: ['ts-loader'] },
{ test: /\.html$/, use: [{ loader: 'html-loader', options: { minimize: false } }] },
{ test: /(\.component|)\.less$/, use: ['to-string-loader', 'css-loader', 'less-loader'] },
{ test: /\.css$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })},
{ test: /\.(png|gif|jpg)$/, use:[{ loader: 'file-loader', options: { name: 'images/[name].[ext]'} } ]},
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{
enforce: 'post',
include: /node_modules\/mapbox-gl-shaders/,
loader: 'transform',
query: 'brfs'
}
],
noParse: [ path.join(__dirname, 'node_modules', 'angular2', 'bundles') ]
},
plugins: [
// uncomment this code for production
// new webpack.optimize.UglifyJsPlugin({
// sourceMap: false,
// mangle: true
// }),
new ExtractTextPlugin("[name].[hash].css"),
new HtmlWebpackPlugin({
template: path.resolve(srcDir, 'index.html'),
inject: true
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'defer'
}),
new OptimizeJsPlugin({
sourceMap: false
}),
new WebpackCleanupPlugin({
exclude: ['index.html']
})
]
};