Files
grafana/scripts/webpack/webpack.prod.js
T

77 lines
2.1 KiB
JavaScript
Raw Normal View History

2017-10-01 20:02:25 +02:00
'use strict';
2021-08-31 12:55:05 +02:00
const { merge } = require('webpack-merge');
2019-03-11 14:56:16 +01:00
const TerserPlugin = require('terser-webpack-plugin');
2017-10-01 20:02:25 +02:00
const common = require('./webpack.common.js');
const path = require('path');
2020-01-30 04:54:11 -05:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2021-08-31 12:55:05 +02:00
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const getBabelConfig = require('./babel.config');
2017-10-01 20:02:25 +02:00
module.exports = merge(common, {
2018-06-26 01:28:37 -07:00
mode: 'production',
2020-01-30 04:54:11 -05:00
devtool: 'source-map',
2017-10-01 20:02:25 +02:00
entry: {
dark: './public/sass/grafana.dark.scss',
light: './public/sass/grafana.light.scss',
},
module: {
2020-01-30 04:54:11 -05:00
// Note: order is bottom-to-top and/or right-to-left
rules: [
2018-04-18 15:01:36 +02:00
{
test: /\.tsx?$/,
exclude: /node_modules/,
2020-01-30 04:54:11 -05:00
use: [
{
loader: 'babel-loader',
options: getBabelConfig(),
2020-01-30 04:54:11 -05:00
},
],
2018-04-18 15:01:36 +02:00
},
2017-10-01 20:02:25 +02:00
require('./sass.rule.js')({
sourceMap: false,
2020-01-30 04:54:11 -05:00
preserveUrl: false,
}),
],
2017-10-01 20:02:25 +02:00
},
2018-06-26 01:28:37 -07:00
optimization: {
nodeEnv: 'production',
2018-06-26 01:28:37 -07:00
minimizer: [
2019-03-11 14:56:16 +01:00
new TerserPlugin({
2020-03-10 11:09:45 +01:00
parallel: false,
2018-06-26 01:28:37 -07:00
}),
2021-08-31 12:55:05 +02:00
new CssMinimizerPlugin(),
2020-01-30 04:54:11 -05:00
],
},
2017-10-01 20:02:25 +02:00
plugins: [
2018-06-26 01:28:37 -07:00
new MiniCssExtractPlugin({
2021-08-31 12:55:05 +02:00
filename: 'grafana.[name].[fullhash].css',
2017-10-01 20:02:25 +02:00
}),
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, '../../public/views/error.html'),
template: path.resolve(__dirname, '../../public/views/error-template.html'),
inject: false,
excludeChunks: ['dark', 'light'],
2020-01-30 04:54:11 -05:00
chunksSortMode: 'none',
}),
2017-10-01 20:02:25 +02:00
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, '../../public/views/index.html'),
2018-11-02 10:49:46 +01:00
template: path.resolve(__dirname, '../../public/views/index-template.html'),
inject: false,
excludeChunks: ['manifest', 'dark', 'light'],
2020-01-30 04:54:11 -05:00
chunksSortMode: 'none',
2017-10-01 20:02:25 +02:00
}),
2021-01-20 07:59:48 +01:00
function () {
this.hooks.done.tap('Done', function (stats) {
2017-10-01 20:02:25 +02:00
if (stats.compilation.errors && stats.compilation.errors.length) {
console.log(stats.compilation.errors);
process.exit(1);
}
});
2020-01-30 04:54:11 -05:00
},
],
2017-10-01 20:02:25 +02:00
});