2017-10-01 13:02:25 -05:00
|
|
|
const path = require('path');
|
2021-09-02 07:18:07 -05:00
|
|
|
const webpack = require('webpack');
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-11-09 11:05:01 -06:00
|
|
|
const CorsWorkerPlugin = require('./plugins/CorsWorkerPlugin');
|
2020-06-29 12:58:47 -05:00
|
|
|
|
2017-10-01 13:02:25 -05:00
|
|
|
module.exports = {
|
|
|
|
target: 'web',
|
|
|
|
entry: {
|
|
|
|
app: './public/app/index.ts',
|
|
|
|
},
|
|
|
|
output: {
|
2021-08-31 05:55:05 -05:00
|
|
|
clean: true,
|
2017-10-01 13:02:25 -05:00
|
|
|
path: path.resolve(__dirname, '../../public/build'),
|
2022-05-26 04:49:18 -05:00
|
|
|
filename: '[name].[contenthash].js',
|
2018-05-07 10:02:55 -05:00
|
|
|
// Keep publicPath relative for host.com/grafana/ deployments
|
2019-03-05 06:29:54 -06:00
|
|
|
publicPath: 'public/build/',
|
2017-10-01 13:02:25 -05:00
|
|
|
},
|
|
|
|
resolve: {
|
2018-10-09 12:46:31 -05:00
|
|
|
extensions: ['.ts', '.tsx', '.es6', '.js', '.json', '.svg'],
|
2020-01-30 03:54:11 -06:00
|
|
|
alias: {
|
2022-05-26 04:49:18 -05:00
|
|
|
// some of data source plugins use global Prism object to add the language definition
|
2020-12-02 07:09:55 -06:00
|
|
|
// we want to have same Prism object in core and in grafana/ui
|
2021-10-27 08:21:07 -05:00
|
|
|
prismjs: require.resolve('prismjs'),
|
2023-04-24 10:13:52 -05:00
|
|
|
// some sub-dependencies use a different version of @emotion/react and generate warnings
|
|
|
|
// in the browser about @emotion/react loaded twice. We want to only load it once
|
|
|
|
'@emotion/react': require.resolve('@emotion/react'),
|
2023-06-21 07:49:22 -05:00
|
|
|
// due to our webpack configuration not understanding package.json `exports`
|
|
|
|
// correctly we must alias this package to the correct file
|
|
|
|
// the alternative to this alias is to copy-paste the file into our
|
|
|
|
// source code and miss out in updates
|
|
|
|
'@locker/near-membrane-dom/custom-devtools-formatter': require.resolve(
|
|
|
|
'@locker/near-membrane-dom/custom-devtools-formatter.js'
|
|
|
|
),
|
2020-01-30 03:54:11 -06:00
|
|
|
},
|
2024-01-30 09:59:18 -06:00
|
|
|
modules: [
|
|
|
|
// default value
|
|
|
|
'node_modules',
|
|
|
|
|
|
|
|
// required for grafana enterprise resolution
|
|
|
|
path.resolve('node_modules'),
|
|
|
|
|
|
|
|
// required to for 'bare' imports (like 'app/core/utils' etc)
|
|
|
|
path.resolve('public'),
|
|
|
|
],
|
2021-08-31 05:55:05 -05:00
|
|
|
fallback: {
|
2021-10-08 09:19:10 -05:00
|
|
|
buffer: false,
|
2021-08-31 05:55:05 -05:00
|
|
|
fs: false,
|
|
|
|
stream: false,
|
2021-09-10 11:05:03 -05:00
|
|
|
http: false,
|
|
|
|
https: false,
|
2021-10-27 08:21:07 -05:00
|
|
|
string_decoder: false,
|
2021-08-31 05:55:05 -05:00
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
},
|
2024-02-22 05:31:40 -06:00
|
|
|
ignoreWarnings: [
|
|
|
|
/export .* was not found in/,
|
|
|
|
{
|
|
|
|
module: /@kusto\/language-service\/bridge\.min\.js$/,
|
|
|
|
message: /^Critical dependency: the request of a dependency is an expression$/,
|
|
|
|
},
|
|
|
|
],
|
2020-06-29 12:58:47 -05:00
|
|
|
plugins: [
|
2023-07-05 09:24:48 -05:00
|
|
|
new webpack.NormalModuleReplacementPlugin(/^@grafana\/schema\/dist\/esm\/(.*)$/, (resource) => {
|
|
|
|
resource.request = resource.request.replace('@grafana/schema/dist/esm', '@grafana/schema/src');
|
|
|
|
}),
|
2021-11-09 11:05:01 -06:00
|
|
|
new CorsWorkerPlugin(),
|
2021-09-02 07:18:07 -05:00
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
Buffer: ['buffer', 'Buffer'],
|
|
|
|
}),
|
2020-06-29 12:58:47 -05:00
|
|
|
],
|
2017-10-01 13:02:25 -05:00
|
|
|
module: {
|
2020-01-23 01:33:39 -06:00
|
|
|
rules: [
|
|
|
|
{
|
2017-10-01 13:02:25 -05:00
|
|
|
test: require.resolve('jquery'),
|
2021-08-31 05:55:05 -05:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: ['$', 'jQuery'],
|
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
2018-11-02 04:49:46 -05:00
|
|
|
exclude: /(index|error)\-template\.html/,
|
2020-01-23 01:33:39 -06:00
|
|
|
use: [
|
|
|
|
{
|
2019-09-03 03:29:02 -05:00
|
|
|
loader: 'ngtemplate-loader?relativeTo=' + path.resolve(__dirname, '../../public') + '&prefix=public',
|
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
{
|
|
|
|
loader: 'html-loader',
|
|
|
|
options: {
|
2021-08-31 05:55:05 -05:00
|
|
|
sources: false,
|
|
|
|
minimize: {
|
|
|
|
removeComments: false,
|
|
|
|
collapseWhitespace: false,
|
|
|
|
},
|
2019-09-03 03:29:02 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-06-29 12:58:47 -05:00
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: ['style-loader', 'css-loader'],
|
|
|
|
},
|
2021-04-01 09:09:56 -05:00
|
|
|
{
|
2022-08-04 03:29:42 -05:00
|
|
|
test: /\.(svg|ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: { filename: 'static/img/[name].[hash:8][ext]' },
|
2021-04-01 09:09:56 -05:00
|
|
|
},
|
2022-08-04 03:29:42 -05:00
|
|
|
// for pre-caching SVGs as part of the JS bundles
|
2020-05-04 08:05:31 -05:00
|
|
|
{
|
2022-08-04 03:29:42 -05:00
|
|
|
test: /(unicons|mono|custom)[\\/].*\.svg$/,
|
|
|
|
type: 'asset/source',
|
2020-05-04 08:05:31 -05:00
|
|
|
},
|
2024-01-31 10:26:12 -06:00
|
|
|
{
|
|
|
|
// Required for msagl library (used in Nodegraph panel) to work
|
|
|
|
test: /\.m?js$/,
|
|
|
|
resolve: {
|
|
|
|
fullySpecified: false,
|
|
|
|
},
|
|
|
|
},
|
2019-09-03 03:29:02 -05:00
|
|
|
],
|
2017-10-01 13:02:25 -05:00
|
|
|
},
|
2019-03-05 06:29:54 -06:00
|
|
|
// https://webpack.js.org/plugins/split-chunks-plugin/#split-chunks-example-3
|
|
|
|
optimization: {
|
2019-09-03 03:29:02 -05:00
|
|
|
runtimeChunk: 'single',
|
2019-03-05 06:29:54 -06:00
|
|
|
splitChunks: {
|
2019-09-03 03:29:02 -05:00
|
|
|
chunks: 'all',
|
|
|
|
minChunks: 1,
|
2019-03-05 06:29:54 -06:00
|
|
|
cacheGroups: {
|
2020-10-19 16:47:47 -05:00
|
|
|
unicons: {
|
|
|
|
test: /[\\/]node_modules[\\/]@iconscout[\\/]react-unicons[\\/].*[jt]sx?$/,
|
|
|
|
chunks: 'initial',
|
|
|
|
priority: 20,
|
|
|
|
enforce: true,
|
|
|
|
},
|
2019-09-03 03:29:02 -05:00
|
|
|
moment: {
|
|
|
|
test: /[\\/]node_modules[\\/]moment[\\/].*[jt]sx?$/,
|
|
|
|
chunks: 'initial',
|
|
|
|
priority: 20,
|
2020-01-23 01:33:39 -06:00
|
|
|
enforce: true,
|
2019-09-03 03:29:02 -05:00
|
|
|
},
|
|
|
|
angular: {
|
|
|
|
test: /[\\/]node_modules[\\/]angular[\\/].*[jt]sx?$/,
|
|
|
|
chunks: 'initial',
|
|
|
|
priority: 50,
|
2020-01-23 01:33:39 -06:00
|
|
|
enforce: true,
|
2019-09-03 03:29:02 -05:00
|
|
|
},
|
2021-08-31 05:55:05 -05:00
|
|
|
defaultVendors: {
|
2019-03-05 06:29:54 -06:00
|
|
|
test: /[\\/]node_modules[\\/].*[jt]sx?$/,
|
2019-09-03 03:29:02 -05:00
|
|
|
chunks: 'initial',
|
|
|
|
priority: -10,
|
|
|
|
reuseExistingChunk: true,
|
2020-01-23 01:33:39 -06:00
|
|
|
enforce: true,
|
2019-09-03 03:29:02 -05:00
|
|
|
},
|
|
|
|
default: {
|
|
|
|
priority: -20,
|
|
|
|
chunks: 'all',
|
|
|
|
test: /.*[jt]sx?$/,
|
2020-01-23 01:33:39 -06:00
|
|
|
reuseExistingChunk: true,
|
2019-09-03 03:29:02 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
};
|