2017-10-01 13:02:25 -05: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");
|
|
|
|
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
2018-04-18 08:01:36 -05:00
|
|
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
2017-10-01 13:02:25 -05:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
|
|
|
2018-04-18 08:01:36 -05:00
|
|
|
const extractSass = new ExtractTextPlugin({
|
2018-05-28 06:49:15 -05:00
|
|
|
filename: "grafana.[name].css"
|
2018-04-18 08:01:36 -05:00
|
|
|
});
|
2017-10-01 13:02:25 -05:00
|
|
|
|
2018-05-28 06:49:15 -05:00
|
|
|
module.exports = merge(common, {
|
|
|
|
devtool: "cheap-module-source-map",
|
|
|
|
|
|
|
|
entry: {
|
2018-04-18 08:01:36 -05:00
|
|
|
app: './public/app/index.ts',
|
2017-10-01 13:02:25 -05:00
|
|
|
dark: './public/sass/grafana.dark.scss',
|
|
|
|
light: './public/sass/grafana.light.scss',
|
2017-10-03 04:02:40 -05:00
|
|
|
vendor: require('./dependencies'),
|
2018-05-28 06:49:15 -05:00
|
|
|
},
|
2018-04-18 08:01:36 -05:00
|
|
|
|
2018-05-28 06:49:15 -05:00
|
|
|
output: {
|
2018-05-14 04:58:15 -05: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 13:02:25 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
2018-04-18 08:01:36 -05: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 04:58:15 -05:00
|
|
|
use: {
|
|
|
|
loader: 'awesome-typescript-loader',
|
|
|
|
options: {
|
|
|
|
useCache: true,
|
2018-04-18 08:01:36 -05:00
|
|
|
},
|
2018-05-14 04:58:15 -05:00
|
|
|
}
|
2018-04-18 08:01:36 -05:00
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
require('./sass.rule.js')({
|
2018-05-28 06:49:15 -05:00
|
|
|
sourceMap: true, minimize: false, preserveUrl: false
|
2018-04-18 08:01:36 -05:00
|
|
|
}, extractSass),
|
|
|
|
{
|
2018-05-28 06:49:15 -05:00
|
|
|
test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
|
2018-04-18 08:01:36 -05:00
|
|
|
loader: 'file-loader'
|
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
2018-06-25 06:45:47 -05:00
|
|
|
new CleanWebpackPlugin('../../public/build', { allowExternal: true }),
|
2018-04-18 08:01:36 -05:00
|
|
|
extractSass,
|
2017-10-01 13:02:25 -05: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 08:01:36 -05:00
|
|
|
new webpack.NamedModulesPlugin(),
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
2017-10-01 13:02:25 -05:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
|
|
|
'NODE_ENV': JSON.stringify('development')
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
names: ['vendor', 'manifest'],
|
|
|
|
}),
|
2017-10-03 05:18:22 -05:00
|
|
|
// new BundleAnalyzerPlugin({
|
|
|
|
// analyzerPort: 8889
|
|
|
|
// })
|
2017-10-01 13:02:25 -05:00
|
|
|
]
|
|
|
|
});
|