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');
|
2018-04-18 08:01:36 -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');
|
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, {
|
|
|
|
devtool: 'cheap-module-source-map',
|
|
|
|
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: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
enforce: 'pre',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'tslint-loader',
|
|
|
|
options: {
|
|
|
|
emitErrors: true,
|
|
|
|
typeCheck: false,
|
|
|
|
},
|
2018-04-18 08:01:36 -05:00
|
|
|
},
|
2018-06-26 03:28:37 -05:00
|
|
|
},
|
2019-08-30 07:02:31 -05:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
transpileOnly: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
require('./sass.rule.js')({ sourceMap: false, preserveUrl: false }),
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
|
|
|
loader: 'file-loader',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
|
2019-08-30 07:02:31 -05:00
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
env.noTsCheck
|
|
|
|
? new webpack.DefinePlugin({}) // bogus plugin to satisfy webpack API
|
|
|
|
: new ForkTsCheckerWebpackPlugin({
|
|
|
|
checkSyntacticErrors: true,
|
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'grafana.[name].[hash].css',
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: path.resolve(__dirname, '../../public/views/error.html'),
|
|
|
|
template: path.resolve(__dirname, '../../public/views/error-template.html'),
|
|
|
|
inject: false,
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: path.resolve(__dirname, '../../public/views/index.html'),
|
|
|
|
template: path.resolve(__dirname, '../../public/views/index-template.html'),
|
|
|
|
inject: 'body',
|
|
|
|
chunks: ['manifest', 'vendor', 'app'],
|
|
|
|
}),
|
|
|
|
new webpack.NamedModulesPlugin(),
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
|
|
|
NODE_ENV: JSON.stringify('development'),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
// new BundleAnalyzerPlugin({
|
|
|
|
// analyzerPort: 8889
|
|
|
|
// })
|
|
|
|
],
|
|
|
|
});
|