grafana/scripts/webpack/webpack.hot.js

120 lines
3.2 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');
const IgnoreNotFoundExportPlugin = require("./IgnoreNotFoundExportPlugin.js");
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,
2018-12-03 09:32:50 -06:00
plugins: [
[require('@rtsao/plugin-proposal-class-properties'), { loose: true }],
'angularjs-annotate',
'@babel/plugin-syntax-dynamic-import', // needed for `() => import()` in routes.ts
2018-12-03 09:32:50 -06:00
'react-hot-loader/babel',
2018-10-29 06:18:41 -05:00
],
2018-12-03 09:32:50 -06:00
presets: [
[
'@babel/preset-env',
{
targets: { browsers: 'last 3 versions' },
useBuiltIns: 'entry',
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
2018-10-31 07:23:05 -05:00
},
},
],
},
{
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
2018-11-23 08:01:36 -06:00
{
loader: 'postcss-loader',
options: {
config: { path: __dirname + '/postcss.config.js' },
},
},
{
loader: 'sass-loader'
}
2018-10-31 07:23:05 -05:00
],
},
{
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(),
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'),
},
}),
new IgnoreNotFoundExportPlugin(),
2018-10-31 07:23:05 -05:00
],
});