2017-10-01 13:02:25 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const merge = require('webpack-merge');
|
2019-03-11 08:56:16 -05:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2017-10-01 13:02:25 -05:00
|
|
|
const common = require('./webpack.common.js');
|
|
|
|
const path = require('path');
|
2019-08-30 07:02:31 -05:00
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
2020-01-30 03:54:11 -06:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
2021-03-31 12:09:19 -05:00
|
|
|
const getBabelConfig = require('./babel.config');
|
2017-10-01 13:02:25 -05:00
|
|
|
|
|
|
|
module.exports = merge(common, {
|
2018-06-26 03:28:37 -05:00
|
|
|
mode: 'production',
|
2020-01-30 03:54:11 -06:00
|
|
|
devtool: 'source-map',
|
2017-10-01 13:02:25 -05:00
|
|
|
|
|
|
|
entry: {
|
|
|
|
dark: './public/sass/grafana.dark.scss',
|
|
|
|
light: './public/sass/grafana.light.scss',
|
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
2020-01-30 03:54:11 -06:00
|
|
|
// Note: order is bottom-to-top and/or right-to-left
|
|
|
|
rules: [
|
2018-04-18 08:01:36 -05:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2020-01-30 03:54:11 -06:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'babel-loader',
|
2021-03-31 12:09:19 -05:00
|
|
|
options: getBabelConfig(),
|
2020-01-30 03:54:11 -06:00
|
|
|
},
|
|
|
|
],
|
2018-04-18 08:01:36 -05:00
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
require('./sass.rule.js')({
|
2019-09-03 03:29:02 -05:00
|
|
|
sourceMap: false,
|
2020-01-30 03:54:11 -06:00
|
|
|
preserveUrl: false,
|
|
|
|
}),
|
|
|
|
],
|
2017-10-01 13:02:25 -05:00
|
|
|
},
|
2018-06-26 03:28:37 -05:00
|
|
|
optimization: {
|
2019-09-03 03:29:02 -05:00
|
|
|
nodeEnv: 'production',
|
2018-06-26 03:28:37 -05:00
|
|
|
minimizer: [
|
2019-03-11 08:56:16 -05:00
|
|
|
new TerserPlugin({
|
2019-03-11 09:23:52 -05:00
|
|
|
cache: false,
|
2020-03-10 05:09:45 -05:00
|
|
|
parallel: false,
|
2020-01-30 03:54:11 -06:00
|
|
|
sourceMap: true,
|
2018-06-26 03:28:37 -05:00
|
|
|
}),
|
2020-01-30 03:54:11 -06:00
|
|
|
new OptimizeCSSAssetsPlugin({}),
|
|
|
|
],
|
2017-10-22 00:03:26 -05:00
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
plugins: [
|
2019-08-30 07:02:31 -05:00
|
|
|
new ForkTsCheckerWebpackPlugin({
|
2020-06-22 09:15:29 -05:00
|
|
|
eslint: {
|
|
|
|
enabled: true,
|
2020-08-11 10:52:44 -05:00
|
|
|
files: ['public/app/**/*.{ts,tsx}', 'packages/*/src/**/*.{ts,tsx}'],
|
2020-06-22 09:15:29 -05:00
|
|
|
},
|
|
|
|
typescript: {
|
|
|
|
mode: 'write-references',
|
|
|
|
memoryLimit: 4096,
|
|
|
|
diagnosticOptions: {
|
|
|
|
semantic: true,
|
|
|
|
syntactic: true,
|
|
|
|
},
|
|
|
|
},
|
2019-08-30 07:02:31 -05:00
|
|
|
}),
|
2018-06-26 03:28:37 -05:00
|
|
|
new MiniCssExtractPlugin({
|
2020-01-30 03:54:11 -06:00
|
|
|
filename: 'grafana.[name].[hash].css',
|
2017-10-01 13:02:25 -05:00
|
|
|
}),
|
2018-11-20 06:46:52 -06:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: path.resolve(__dirname, '../../public/views/error.html'),
|
|
|
|
template: path.resolve(__dirname, '../../public/views/error-template.html'),
|
|
|
|
inject: false,
|
2019-09-03 03:29:02 -05:00
|
|
|
excludeChunks: ['dark', 'light'],
|
2020-01-30 03:54:11 -06:00
|
|
|
chunksSortMode: 'none',
|
2018-11-20 06:46:52 -06:00
|
|
|
}),
|
2017-10-01 13:02:25 -05:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: path.resolve(__dirname, '../../public/views/index.html'),
|
2018-11-02 04:49:46 -05:00
|
|
|
template: path.resolve(__dirname, '../../public/views/index-template.html'),
|
2019-12-05 01:30:39 -06:00
|
|
|
inject: false,
|
2019-09-03 03:29:02 -05:00
|
|
|
excludeChunks: ['manifest', 'dark', 'light'],
|
2020-01-30 03:54:11 -06:00
|
|
|
chunksSortMode: 'none',
|
2017-10-01 13:02:25 -05:00
|
|
|
}),
|
2021-01-20 00:59:48 -06:00
|
|
|
function () {
|
|
|
|
this.hooks.done.tap('Done', function (stats) {
|
2017-10-01 13:02:25 -05:00
|
|
|
if (stats.compilation.errors && stats.compilation.errors.length) {
|
|
|
|
console.log(stats.compilation.errors);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
2020-01-30 03:54:11 -06:00
|
|
|
},
|
|
|
|
],
|
2017-10-01 13:02:25 -05:00
|
|
|
});
|