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

103 lines
2.6 KiB
JavaScript
Raw Normal View History

2017-10-01 20:02:25 +02:00
'use strict';
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require("html-webpack-plugin");
2018-04-18 15:01:36 +02:00
const CleanWebpackPlugin = require('clean-webpack-plugin');
2018-06-26 01:28:37 -07:00
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
2017-10-01 20:02:25 +02:00
2018-05-28 13:49:15 +02:00
module.exports = merge(common, {
devtool: "cheap-module-source-map",
2018-06-26 01:28:37 -07:00
mode: 'development',
2018-05-28 13:49:15 +02:00
entry: {
2018-04-18 15:01:36 +02:00
app: './public/app/index.ts',
2017-10-01 20:02:25 +02:00
dark: './public/sass/grafana.dark.scss',
light: './public/sass/grafana.light.scss',
2018-05-28 13:49:15 +02:00
},
2018-04-18 15:01:36 +02:00
2018-05-28 13:49:15 +02:00
output: {
2018-05-14 11:58:15 +02:00
path: path.resolve(__dirname, '../../public/build'),
filename: '[name].[hash].js',
// Keep publicPath relative for host.com/grafana/ deployments
publicPath: "public/build/",
2017-10-01 20:02:25 +02:00
},
module: {
rules: [
2018-04-18 15:01:36 +02:00
{
test: /\.tsx?$/,
enforce: 'pre',
exclude: /node_modules/,
use: {
loader: 'tslint-loader',
options: {
emitErrors: true,
typeCheck: false,
}
}
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
2018-05-14 11:58:15 +02:00
use: {
2018-06-26 01:28:37 -07:00
loader: 'ts-loader',
2018-05-14 11:58:15 +02:00
options: {
2018-06-26 01:28:37 -07:00
transpileOnly: true
2018-04-18 15:01:36 +02:00
},
2018-06-26 01:28:37 -07:00
},
2018-04-18 15:01:36 +02:00
},
2018-06-26 01:28:37 -07:00
require('./sass.rule.js')({ sourceMap: false, minimize: false, preserveUrl: false }),
2018-04-18 15:01:36 +02:00
{
2018-05-28 13:49:15 +02:00
test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
2018-04-18 15:01:36 +02:00
loader: 'file-loader'
},
2017-10-01 20:02:25 +02:00
]
},
2018-06-26 01:28:37 -07:00
optimization: {
splitChunks: {
cacheGroups: {
manifest: {
chunks: "initial",
test: "vendor",
name: "vendor",
enforce: true
},
vendor: {
chunks: "initial",
test: "vendor",
name: "vendor",
enforce: true
}
}
}
},
2017-10-01 20:02:25 +02:00
plugins: [
new CleanWebpackPlugin('../../public/build', { allowExternal: true }),
2018-06-26 01:28:37 -07:00
new MiniCssExtractPlugin({
filename: "grafana.[name].css"
}),
2017-10-01 20:02:25 +02:00
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'],
}),
2018-04-18 15:01:36 +02:00
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
2017-10-01 20:02:25 +02:00
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('development')
}
}),
// new BundleAnalyzerPlugin({
// analyzerPort: 8889
// })
2017-10-01 20:02:25 +02:00
]
});