2017-10-02 02:02:25 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const merge = require('webpack-merge');
|
2019-03-11 21:56:16 +08:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2017-10-02 02:02:25 +08:00
|
|
|
const common = require('./webpack.common.js');
|
|
|
|
const path = require('path');
|
2020-01-17 22:52:56 +08:00
|
|
|
const ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
|
2019-08-30 20:02:31 +08:00
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
2020-01-17 22:52:56 +08:00
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
2017-10-02 02:02:25 +08:00
|
|
|
|
|
|
|
module.exports = merge(common, {
|
2018-06-26 16:28:37 +08:00
|
|
|
mode: 'production',
|
2020-01-17 22:52:56 +08:00
|
|
|
devtool: "source-map",
|
2017-10-02 02:02:25 +08:00
|
|
|
|
|
|
|
entry: {
|
|
|
|
dark: './public/sass/grafana.dark.scss',
|
|
|
|
light: './public/sass/grafana.light.scss',
|
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
2020-01-17 22:52:56 +08:00
|
|
|
rules: [{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
enforce: 'pre',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'tslint-loader',
|
|
|
|
options: {
|
|
|
|
emitErrors: true,
|
|
|
|
typeCheck: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-04-18 21:01:36 +08:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2020-01-17 22:52:56 +08:00
|
|
|
use: {
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
transpileOnly: true
|
2018-04-26 17:58:42 +08:00
|
|
|
},
|
2020-01-17 22:52:56 +08:00
|
|
|
},
|
2018-04-18 21:01:36 +08:00
|
|
|
},
|
2017-10-02 02:02:25 +08:00
|
|
|
require('./sass.rule.js')({
|
2019-09-03 16:29:02 +08:00
|
|
|
sourceMap: false,
|
2020-01-17 22:52:56 +08:00
|
|
|
preserveUrl: false
|
|
|
|
})
|
|
|
|
]
|
2017-10-02 02:02:25 +08:00
|
|
|
},
|
2018-06-26 16:28:37 +08:00
|
|
|
optimization: {
|
2019-09-03 16:29:02 +08:00
|
|
|
nodeEnv: 'production',
|
2018-06-26 16:28:37 +08:00
|
|
|
minimizer: [
|
2019-03-11 21:56:16 +08:00
|
|
|
new TerserPlugin({
|
2019-03-11 22:23:52 +08:00
|
|
|
cache: false,
|
2018-06-26 16:28:37 +08:00
|
|
|
parallel: true,
|
2020-01-17 22:52:56 +08:00
|
|
|
sourceMap: true
|
2018-06-26 16:28:37 +08:00
|
|
|
}),
|
2020-01-17 22:52:56 +08:00
|
|
|
new OptimizeCSSAssetsPlugin({})
|
|
|
|
]
|
2017-10-22 13:03:26 +08:00
|
|
|
},
|
2017-10-02 02:02:25 +08:00
|
|
|
plugins: [
|
2019-08-30 20:02:31 +08:00
|
|
|
new ForkTsCheckerWebpackPlugin({
|
|
|
|
checkSyntacticErrors: true,
|
|
|
|
}),
|
2018-06-26 16:28:37 +08:00
|
|
|
new MiniCssExtractPlugin({
|
2020-01-17 22:52:56 +08:00
|
|
|
filename: "grafana.[name].[hash].css"
|
2017-10-02 02:02:25 +08:00
|
|
|
}),
|
2020-01-17 22:52:56 +08:00
|
|
|
new ngAnnotatePlugin(),
|
2018-11-20 20:46:52 +08: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 16:29:02 +08:00
|
|
|
excludeChunks: ['dark', 'light'],
|
2020-01-17 22:52:56 +08:00
|
|
|
chunksSortMode: 'none'
|
2018-11-20 20:46:52 +08:00
|
|
|
}),
|
2017-10-02 02:02:25 +08:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: path.resolve(__dirname, '../../public/views/index.html'),
|
2018-11-02 17:49:46 +08:00
|
|
|
template: path.resolve(__dirname, '../../public/views/index-template.html'),
|
2019-12-05 15:30:39 +08:00
|
|
|
inject: false,
|
2019-09-03 16:29:02 +08:00
|
|
|
excludeChunks: ['manifest', 'dark', 'light'],
|
2020-01-17 22:52:56 +08:00
|
|
|
chunksSortMode: 'none'
|
2017-10-02 02:02:25 +08:00
|
|
|
}),
|
2020-01-17 22:52:56 +08:00
|
|
|
function () {
|
|
|
|
this.hooks.done.tap('Done', function (stats) {
|
2017-10-02 02:02:25 +08:00
|
|
|
if (stats.compilation.errors && stats.compilation.errors.length) {
|
|
|
|
console.log(stats.compilation.errors);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
2020-01-17 22:52:56 +08:00
|
|
|
}
|
|
|
|
]
|
2017-10-02 02:02:25 +08:00
|
|
|
});
|