grafana/scripts/webpack/webpack.hot.js

101 lines
2.6 KiB
JavaScript
Raw Normal View History

'use strict';
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const webpack = require('webpack');
2018-10-31 07:23:05 -05:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = merge(common, {
entry: {
2018-10-31 07:23:05 -05:00
app: ['webpack-dev-server/client?http://localhost:3333', './public/app/dev.ts'],
},
output: {
path: path.resolve(__dirname, '../../public/build'),
filename: '[name].[hash].js',
2018-10-31 07:23:05 -05:00
publicPath: '/public/build/',
pathinfo: false,
},
resolve: {
extensions: ['.scss', '.ts', '.tsx', '.es6', '.js', '.json', '.svg', '.woff2', '.png', '.html'],
},
2018-05-28 10:38:09 -05:00
devtool: 'eval-source-map',
devServer: {
publicPath: '/public/build/',
hot: true,
port: 3333,
proxy: {
2018-10-31 07:23:05 -05:00
'!/public/build': 'http://localhost:3000',
},
},
optimization: {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
},
module: {
rules: [
{
2018-11-01 08:03:02 -05:00
test: /\.tsx?$/,
exclude: /node_modules/,
2018-10-31 07:23:05 -05:00
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
plugins: ['syntax-dynamic-import', 'react-hot-loader/babel'],
},
},
2018-10-31 07:23:05 -05:00
{
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
},
],
},
{
test: /\.scss$/,
use: [
2018-10-31 07:23:05 -05:00
'style-loader', // creates style nodes from JS strings
'css-loader', // translates CSS into CommonJS
'sass-loader', // compiles Sass to CSS
],
},
{
test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
2018-10-31 07:23:05 -05:00
loader: 'file-loader',
},
2018-10-31 07:23:05 -05:00
],
},
plugins: [
new CleanWebpackPlugin('../public/build', { allowExternal: true }),
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, '../../public/views/index.html'),
2018-11-02 04:49:46 -05:00
template: path.resolve(__dirname, '../../public/views/index-template.html'),
inject: 'body',
2018-10-31 07:23:05 -05:00
alwaysWriteToDisk: true,
}),
new HtmlWebpackHarddiskPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
2018-10-31 07:23:05 -05:00
GRAFANA_THEME: JSON.stringify(process.env.GRAFANA_THEME || 'dark'),
'process.env': {
2018-10-31 07:23:05 -05:00
NODE_ENV: JSON.stringify('development'),
},
}),
2018-10-31 07:23:05 -05:00
],
});