grafana/scripts/webpack/webpack.hot.js

108 lines
2.7 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 getBabelConfig = require('./babel.config');
module.exports = merge(common, {
mode: 'development',
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',
},
watchOptions: {
ignored: /node_modules/,
},
},
optimization: {
removeAvailableModules: false,
runtimeChunk: false,
removeEmptyChunks: false,
splitChunks: false,
},
module: {
// Note: order is bottom-to-top and/or right-to-left
rules: [
{
2018-11-01 08:03:02 -05:00
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: getBabelConfig(),
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',
},
2018-11-23 08:01:36 -06:00
},
},
{
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,
chunksSortMode: 'none',
}),
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
],
});