2017-10-01 13:02:25 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const merge = require('webpack-merge');
|
|
|
|
const common = require('./webpack.common.js');
|
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
2019-08-30 07:02:31 -05:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2020-03-16 04:52:30 -05:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2019-08-30 07:02:31 -05:00
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2021-03-31 12:09:19 -05:00
|
|
|
const getBabelConfig = require('./babel.config');
|
2018-06-26 03:28:37 -05:00
|
|
|
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2017-10-01 13:02:25 -05:00
|
|
|
|
2019-08-30 07:02:31 -05:00
|
|
|
module.exports = (env = {}) =>
|
|
|
|
merge(common, {
|
2020-12-29 23:03:53 -06:00
|
|
|
devtool: 'inline-source-map',
|
2019-08-30 07:02:31 -05:00
|
|
|
mode: 'development',
|
2018-05-28 06:49:15 -05:00
|
|
|
|
2019-08-30 07:02:31 -05:00
|
|
|
entry: {
|
|
|
|
app: './public/app/index.ts',
|
|
|
|
dark: './public/sass/grafana.dark.scss',
|
|
|
|
light: './public/sass/grafana.light.scss',
|
|
|
|
},
|
2018-04-18 08:01:36 -05:00
|
|
|
|
2019-08-30 07:02:31 -05:00
|
|
|
// If we enabled watch option via CLI
|
|
|
|
watchOptions: {
|
|
|
|
ignored: /node_modules/,
|
|
|
|
},
|
2019-07-19 23:46:41 -05:00
|
|
|
|
2019-08-30 07:02:31 -05:00
|
|
|
module: {
|
2020-01-30 03:54:11 -06:00
|
|
|
// Note: order is bottom-to-top and/or right-to-left
|
|
|
|
rules: [
|
2019-08-30 07:02:31 -05:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2020-01-30 03:54:11 -06:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'babel-loader',
|
2021-04-01 03:32:00 -05:00
|
|
|
options: getBabelConfig({ BABEL_ENV: 'dev' }),
|
2019-08-30 07:02:31 -05:00
|
|
|
},
|
2020-01-30 03:54:11 -06:00
|
|
|
],
|
2019-08-30 07:02:31 -05:00
|
|
|
},
|
2019-09-03 03:29:02 -05:00
|
|
|
require('./sass.rule.js')({
|
|
|
|
sourceMap: false,
|
2020-01-30 03:54:11 -06:00
|
|
|
preserveUrl: false,
|
2019-09-03 03:29:02 -05:00
|
|
|
}),
|
2020-01-30 03:54:11 -06:00
|
|
|
],
|
2019-08-30 07:02:31 -05:00
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
|
2019-08-30 07:02:31 -05:00
|
|
|
plugins: [
|
2020-04-22 00:49:04 -05:00
|
|
|
new CleanWebpackPlugin(),
|
2020-01-30 03:54:11 -06:00
|
|
|
env.noTsCheck
|
|
|
|
? new webpack.DefinePlugin({}) // bogus plugin to satisfy webpack API
|
|
|
|
: new ForkTsCheckerWebpackPlugin({
|
2020-10-01 03:50:56 -05:00
|
|
|
eslint: {
|
|
|
|
enabled: true,
|
|
|
|
files: ['public/app/**/*.{ts,tsx}', 'packages/*/src/**/*.{ts,tsx}'],
|
|
|
|
options: {
|
|
|
|
cache: true,
|
|
|
|
},
|
2021-04-06 07:51:35 -05:00
|
|
|
memoryLimit: 4096,
|
2020-06-22 09:15:29 -05:00
|
|
|
},
|
2020-10-01 03:50:56 -05:00
|
|
|
typescript: {
|
|
|
|
mode: 'write-references',
|
2021-04-06 07:51:35 -05:00
|
|
|
memoryLimit: 4096,
|
2020-10-01 03:50:56 -05:00
|
|
|
diagnosticOptions: {
|
|
|
|
semantic: true,
|
|
|
|
syntactic: true,
|
|
|
|
},
|
2020-06-22 09:15:29 -05:00
|
|
|
},
|
2020-10-01 03:50:56 -05:00
|
|
|
}),
|
2019-08-30 07:02:31 -05:00
|
|
|
new MiniCssExtractPlugin({
|
2020-01-30 03:54:11 -06:00
|
|
|
filename: 'grafana.[name].[hash].css',
|
2019-08-30 07:02:31 -05: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
|
|
|
chunksSortMode: 'none',
|
2020-01-30 03:54:11 -06:00
|
|
|
excludeChunks: ['dark', 'light'],
|
2019-08-30 07:02:31 -05:00
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: path.resolve(__dirname, '../../public/views/index.html'),
|
|
|
|
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
|
|
|
chunksSortMode: 'none',
|
2020-01-30 03:54:11 -06:00
|
|
|
excludeChunks: ['dark', 'light'],
|
2019-08-30 07:02:31 -05:00
|
|
|
}),
|
|
|
|
new webpack.NamedModulesPlugin(),
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
2020-01-30 03:54:11 -06:00
|
|
|
NODE_ENV: JSON.stringify('development'),
|
|
|
|
},
|
2019-08-30 07:02:31 -05:00
|
|
|
}),
|
|
|
|
// new BundleAnalyzerPlugin({
|
|
|
|
// analyzerPort: 8889
|
|
|
|
// })
|
2020-01-30 03:54:11 -06:00
|
|
|
],
|
2019-08-30 07:02:31 -05:00
|
|
|
});
|