blob: 52ef1f6b372b1becffa93fba1a4930a7180d2d29 [file] [log] [blame]
Monty Taylor4a781a72017-07-25 07:28:04 -04001const path = require('path');
2const webpack = require('webpack');
3const HtmlWebpackPlugin = require('html-webpack-plugin');
4const CleanWebpackPlugin = require('clean-webpack-plugin');
5
6module.exports = {
7 entry: {
8 main: './web/main.js',
9 // Tell webpack to extract 3rd party depdenencies which change less
10 // frequently.
11 vendor: [
12 'angular',
13 'bootstrap/dist/css/bootstrap.css',
14 'jquery-visibility/jquery-visibility',
15 'graphitejs/jquery.graphite.js'
16 ]
17 },
18 output: {
19 filename: '[name].js',
20 // path.resolve(__dirname winds up relative to the config dir
21 path: path.resolve(__dirname, '../../zuul/web/static'),
22 publicPath: ''
23 },
24 // Some folks prefer "cheaper" source-map for dev and one that is more
25 // expensive to build for prod. Debugging without the full source-map sucks,
26 // so define it here in common.
27 devtool: 'source-map',
28 plugins: [
29 new webpack.ProvidePlugin({
30 $: 'jquery/dist/jquery',
31 jQuery: 'jquery/dist/jquery',
32 }),
33 new webpack.optimize.CommonsChunkPlugin({
34 name: 'vendor',
35 }),
36 new webpack.optimize.CommonsChunkPlugin({
37 name: 'manifest',
38 }),
39 new CleanWebpackPlugin(
40 ['zuul/web/static'], { root: path.resolve(__dirname, '../..')}),
41 // Each of the entries below lists a specific 'chunk' which is one of the
42 // entry items from above. We can collapse this to just do one single
43 // output file.
44 new HtmlWebpackPlugin({
45 filename: 'status.html',
46 template: 'web/templates/status.ejs',
47 title: 'Zuul Status'
48 }),
49 new HtmlWebpackPlugin({
50 title: 'Zuul Builds',
51 template: 'web/templates/builds.ejs',
52 filename: 'builds.html'
53 }),
54 new HtmlWebpackPlugin({
55 title: 'Zuul Jobs',
56 template: 'web/templates/jobs.ejs',
57 filename: 'jobs.html'
58 }),
59 new HtmlWebpackPlugin({
60 title: 'Zuul Tenants',
61 template: 'web/templates/tenants.ejs',
62 filename: 'tenants.html'
63 }),
64 new HtmlWebpackPlugin({
65 title: 'Zuul Console Stream',
66 template: 'web/templates/stream.ejs',
67 filename: 'stream.html'
68 })
69 ],
70 module: {
71 rules: [
72 {
73 test: /\.js$/,
74 exclude: /node_modules/,
75 use: [
76 'babel-loader'
77 ]
78 },
79 {
80 test: /.css$/,
81 use: [
82 'style-loader',
83 'css-loader'
84 ]
85 },
86 {
87 test: /\.(png|svg|jpg|gif)$/,
88 use: ['file-loader'],
89 },
90 // The majority of the rules below are all about getting bootstrap copied
91 // appropriately.
92 {
93 test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
94 use: {
95 loader: "url-loader",
96 options: {
97 limit: 10000,
98 mimetype: 'application/font-woff'
99 }
100 }
101 },
102 {
103 test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
104 use: {
105 loader: "url-loader",
106 options: {
107 limit: 10000,
108 mimetype: 'application/octet-stream'
109 }
110 }
111 },
112 {
113 test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
114 use: ['file-loader'],
115 },
116 {
117 test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
118 use: {
119 loader: "url-loader",
120 options: {
121 limit: 10000,
122 mimetype: 'image/svg+xml'
123 }
124 }
125 },
126 {
127 test: /\.html$/,
128 use: ['raw-loader'],
129 exclude: /node_modules/
130 },
131 {
132 test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
133 use: ['file-loader']
134 }
135 ]
136 }
137};