blob: 52ef1f6b372b1becffa93fba1a4930a7180d2d29 [file] [log] [blame]
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
main: './web/main.js',
// Tell webpack to extract 3rd party depdenencies which change less
// frequently.
vendor: [
'angular',
'bootstrap/dist/css/bootstrap.css',
'jquery-visibility/jquery-visibility',
'graphitejs/jquery.graphite.js'
]
},
output: {
filename: '[name].js',
// path.resolve(__dirname winds up relative to the config dir
path: path.resolve(__dirname, '../../zuul/web/static'),
publicPath: ''
},
// Some folks prefer "cheaper" source-map for dev and one that is more
// expensive to build for prod. Debugging without the full source-map sucks,
// so define it here in common.
devtool: 'source-map',
plugins: [
new webpack.ProvidePlugin({
$: 'jquery/dist/jquery',
jQuery: 'jquery/dist/jquery',
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
}),
new CleanWebpackPlugin(
['zuul/web/static'], { root: path.resolve(__dirname, '../..')}),
// Each of the entries below lists a specific 'chunk' which is one of the
// entry items from above. We can collapse this to just do one single
// output file.
new HtmlWebpackPlugin({
filename: 'status.html',
template: 'web/templates/status.ejs',
title: 'Zuul Status'
}),
new HtmlWebpackPlugin({
title: 'Zuul Builds',
template: 'web/templates/builds.ejs',
filename: 'builds.html'
}),
new HtmlWebpackPlugin({
title: 'Zuul Jobs',
template: 'web/templates/jobs.ejs',
filename: 'jobs.html'
}),
new HtmlWebpackPlugin({
title: 'Zuul Tenants',
template: 'web/templates/tenants.ejs',
filename: 'tenants.html'
}),
new HtmlWebpackPlugin({
title: 'Zuul Console Stream',
template: 'web/templates/stream.ejs',
filename: 'stream.html'
})
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
'babel-loader'
]
},
{
test: /.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader'],
},
// The majority of the rules below are all about getting bootstrap copied
// appropriately.
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: "url-loader",
options: {
limit: 10000,
mimetype: 'application/font-woff'
}
}
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: "url-loader",
options: {
limit: 10000,
mimetype: 'application/octet-stream'
}
}
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
use: ['file-loader'],
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: "url-loader",
options: {
limit: 10000,
mimetype: 'image/svg+xml'
}
}
},
{
test: /\.html$/,
use: ['raw-loader'],
exclude: /node_modules/
},
{
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
use: ['file-loader']
}
]
}
};