bitque/jirs-client/webpack.config.js

85 lines
2.4 KiB
JavaScript
Raw Normal View History

2020-03-29 19:56:55 +02:00
const path = require("path");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
2020-03-30 14:26:25 +02:00
const dotenv = require('dotenv');
const webpack = require('webpack');
2020-04-04 17:42:02 +02:00
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
process.env.RUST_LOG = 'info';
2020-03-30 14:26:25 +02:00
dotenv.config();
2020-03-29 19:56:55 +02:00
module.exports = {
2020-04-04 17:42:02 +02:00
entry: path.resolve(__dirname, 'js', 'index.js'),
output: {
filename: '[name].js',
path: path.resolve(__dirname, process.env.NODE_ENV === 'production' ? 'dist' : 'dev'),
2020-03-29 19:56:55 +02:00
publicPath: '/',
},
2020-04-04 17:42:02 +02:00
devtool: 'source-map',
2020-03-29 19:56:55 +02:00
devServer: {
2020-04-04 17:42:02 +02:00
contentBase: path.join(__dirname, 'dev'),
2020-03-29 19:56:55 +02:00
historyApiFallback: true,
2020-04-04 17:42:02 +02:00
hot: true,
port: process.env.JIRS_CLIENT_PORT || 6000,
host: process.env.JIRS_CLIENT_BIND || '0.0.0.0',
allowedHosts: [
2020-03-30 14:26:25 +02:00
'localhost:6000',
2020-03-29 19:56:55 +02:00
'localhost:8000',
],
2020-04-04 17:42:02 +02:00
headers: {
2020-03-29 19:56:55 +02:00
'Access-Control-Allow-Origin': '*',
}
},
2020-04-04 17:42:02 +02:00
module: {
2020-03-30 14:26:25 +02:00
rules: [
{
test: /\.css$/i,
2020-04-04 17:42:02 +02:00
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
// options: { importLoaders: 1 }
},
// 'postcss-loader'
],
2020-03-30 14:26:25 +02:00
},
2020-04-04 17:42:02 +02:00
{
test: /\.svg$/,
use: [
{ loader: 'file-loader' },
{
loader: 'svgo-loader',
options: {
externalConfig: "svgo-config.yml"
}
}
]
}
2020-03-30 14:26:25 +02:00
],
},
2020-04-04 17:42:02 +02:00
plugins: [
2020-03-29 19:56:55 +02:00
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname),
2020-04-10 08:09:40 +02:00
extraArgs: '--no-typescript'
2020-03-29 19:56:55 +02:00
}),
2020-03-30 08:16:26 +02:00
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "js", "template.ejs"),
}),
2020-03-30 14:26:25 +02:00
new webpack.EnvironmentPlugin([
'NODE_ENV',
'DEBUG',
'JIRS_CLIENT_PORT',
'JIRS_CLIENT_BIND',
'JIRS_SERVER_PORT',
'JIRS_SERVER_BIND',
]),
2020-04-04 17:42:02 +02:00
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
ignoreOrder: true,
}),
2020-03-29 19:56:55 +02:00
]
};