redoc/demo/webpack.config.ts
2018-03-13 12:58:22 +02:00

74 lines
1.6 KiB
TypeScript

import * as webpack from 'webpack';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
const VERSION = JSON.stringify(require('../package.json').version);
const REVISION = JSON.stringify(
require('child_process')
.execSync('git rev-parse --short HEAD')
.toString()
.trim(),
);
export default {
entry: __dirname + '/index.tsx',
output: {
filename: 'redoc-demo.bundle.js',
path: __dirname + '/dist',
},
devServer: {
contentBase: __dirname,
watchContentBase: true,
port: 8081,
stats: 'errors-only',
},
devtool: 'eval',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
},
module: {
rules: [
{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader' },
{ test: [/\.eot$/, /\.gif$/, /\.woff$/, /\.svg$/, /\.ttf$/], use: 'null-loader' },
{
test: /\.tsx?$/,
use: [
'react-hot-loader/webpack',
{
loader: 'awesome-typescript-loader',
options: {
module: 'es2015',
},
},
],
exclude: ['node_modules'],
},
{
test: /\.css$/,
use: {
loader: 'css-loader',
options: {
sourceMap: true,
minimize: true,
},
},
},
],
},
plugins: [
new webpack.DefinePlugin({
__REDOC_VERSION__: VERSION,
__REDOC_REVISION__: REVISION,
__REDOC_DEV__: false,
}),
new webpack.NamedModulesPlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
new HtmlWebpackPlugin({
template: 'demo/index.html',
}),
],
};