fluence-js/webpack.config.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-05-14 15:20:39 +03:00
const path = require('path');
const webpack = require('webpack');
2020-10-05 17:17:04 +03:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
2020-05-14 15:20:39 +03:00
const production = (process.env.NODE_ENV === 'production');
const config = {
entry: './src/index.ts',
2020-05-14 15:20:39 +03:00
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.spec\.ts$/,
use: 'mocha-loader',
exclude: /node_modules/,
},
2020-05-14 15:20:39 +03:00
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js']
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'bundle'),
},
node: {
fs: 'empty'
},
plugins: [
2020-10-05 17:17:04 +03:00
new HtmlWebpackPlugin(),
new webpack.ProvidePlugin({
TextDecoder: ['text-encoding', 'TextDecoder'],
TextEncoder: ['text-encoding', 'TextEncoder']
})
2020-05-14 15:20:39 +03:00
]
};
if (production) {
config.mode = 'production';
} else {
config.mode = 'development';
config.devtool = 'inline-source-map';
config.devServer = {
contentBase: './bundle',
hot: false
};
config.plugins = [
...config.plugins,
new webpack.HotModuleReplacementPlugin()
];
}
module.exports = config;