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

99 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-05-28 13:49:15 +02:00
'use strict';
2021-08-31 12:55:05 +02:00
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
2018-10-31 13:23:05 +01:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
2021-08-31 12:55:05 +02:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2022-04-22 14:33:13 +01:00
const path = require('path');
const { DefinePlugin } = require('webpack');
const { merge } = require('webpack-merge');
const HTMLWebpackCSSChunks = require('./plugins/HTMLWebpackCSSChunks');
2022-04-22 14:33:13 +01:00
const common = require('./webpack.common.js');
2018-05-28 13:49:15 +02:00
module.exports = merge(common, {
2021-08-31 12:55:05 +02:00
devtool: 'inline-source-map',
mode: 'development',
2018-05-28 13:49:15 +02:00
2021-08-31 12:55:05 +02:00
entry: {
app: ['./public/app/index.ts'],
dark: './public/sass/grafana.dark.scss',
light: './public/sass/grafana.light.scss',
2018-05-28 13:49:15 +02:00
},
2021-08-31 12:55:05 +02:00
watchOptions: {
ignored: /node_modules/,
2018-05-28 13:49:15 +02:00
},
devServer: {
2021-08-31 12:55:05 +02:00
devMiddleware: {
writeToDisk: true,
},
historyApiFallback: true,
2018-05-28 13:49:15 +02:00
hot: true,
2021-08-31 12:55:05 +02:00
open: false,
2018-05-28 13:49:15 +02:00
port: 3333,
proxy: {
2018-10-31 13:23:05 +01:00
'!/public/build': 'http://localhost:3000',
},
2021-08-31 12:55:05 +02:00
static: {
publicPath: '/public/build/',
2020-01-30 04:54:11 -05:00
},
2018-05-28 13:49:15 +02:00
},
module: {
2020-01-30 04:54:11 -05:00
// Note: order is bottom-to-top and/or right-to-left
rules: [
{
2018-11-01 14:03:02 +01:00
test: /\.tsx?$/,
2021-08-31 12:55:05 +02:00
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
cacheCompression: false,
},
2021-08-31 12:55:05 +02:00
},
2018-05-28 13:49:15 +02:00
exclude: /node_modules/,
2021-08-31 12:55:05 +02:00
include: [path.resolve(__dirname, '../../public/'), path.resolve(__dirname, '../../packages/')],
2018-05-28 13:49:15 +02:00
},
2021-08-31 12:55:05 +02:00
require('./sass.rule.js')({
sourceMap: false,
preserveUrl: false,
}),
2018-10-31 13:23:05 +01:00
],
2018-05-28 13:49:15 +02:00
},
2021-08-31 12:55:05 +02:00
// https://webpack.js.org/guides/build-performance/#output-without-path-info
output: {
filename: '[name].js',
pathinfo: false,
},
// https://webpack.js.org/guides/build-performance/#avoid-extra-optimization-steps
optimization: {
runtimeChunk: true,
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
},
2018-05-28 13:49:15 +02:00
plugins: [
2021-08-31 12:55:05 +02:00
new MiniCssExtractPlugin({
filename: 'grafana.[name].[contenthash].css',
2021-08-31 12:55:05 +02:00
}),
2018-05-28 13:49:15 +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'),
2021-08-31 12:55:05 +02:00
inject: false,
2020-01-30 04:54:11 -05:00
chunksSortMode: 'none',
2021-08-31 12:55:05 +02:00
excludeChunks: ['dark', 'light'],
2018-05-28 13:49:15 +02:00
}),
new HTMLWebpackCSSChunks(),
2021-08-31 12:55:05 +02:00
new ReactRefreshWebpackPlugin(),
new DefinePlugin({
2018-05-28 13:49:15 +02:00
'process.env': {
2018-10-31 13:23:05 +01:00
NODE_ENV: JSON.stringify('development'),
},
2018-05-28 13:49:15 +02:00
}),
2018-10-31 13:23:05 +01:00
],
2018-05-28 13:49:15 +02:00
});