| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 'use strict';
- const merge = require('webpack-merge');
- const common = require('./webpack.common.js');
- const monaco = require('./webpack.monaco.js');
- const path = require('path');
- const webpack = require('webpack');
- const HtmlWebpackPlugin = require("html-webpack-plugin");
- const CleanWebpackPlugin = require('clean-webpack-plugin');
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
- // const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
- module.exports = merge(common, monaco, {
- devtool: "cheap-module-source-map",
- mode: 'development',
- entry: {
- app: './public/app/index.ts',
- dark: './public/sass/grafana.dark.scss',
- light: './public/sass/grafana.light.scss',
- },
- output: {
- path: path.resolve(__dirname, '../../public/build'),
- filename: '[name].[hash].js',
- // Keep publicPath relative for host.com/grafana/ deployments
- publicPath: "public/build/",
- },
- module: {
- rules: [
- {
- test: /\.tsx?$/,
- enforce: 'pre',
- exclude: /node_modules/,
- use: {
- loader: 'tslint-loader',
- options: {
- emitErrors: true,
- typeCheck: false,
- }
- }
- },
- {
- test: /\.tsx?$/,
- exclude: /node_modules/,
- use: {
- loader: 'ts-loader',
- options: {
- transpileOnly: true
- },
- },
- },
- require('./sass.rule.js')({ sourceMap: false, minimize: false, preserveUrl: false }),
- {
- test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
- loader: 'file-loader'
- },
- ]
- },
- optimization: {
- splitChunks: {
- cacheGroups: {
- manifest: {
- chunks: "initial",
- test: "vendor",
- name: "vendor",
- enforce: true
- },
- vendor: {
- chunks: "initial",
- test: "vendor",
- name: "vendor",
- enforce: true
- }
- }
- }
- },
- plugins: [
- new CleanWebpackPlugin('../../public/build', { allowExternal: 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
- // })
- ]
- });
|