Web-Control-Panel-PWA/webpack.config.js
2022-03-04 20:29:15 +01:00

69 lines
1.6 KiB
JavaScript

const path = require('path');
const fs = require('fs');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// App directory
const appDirectory = fs.realpathSync(process.cwd());
// Gets absolute path of file within app directory
const resolveAppPath = relativePath => path.resolve(appDirectory, relativePath);
// Host
const host = process.env.HOST || 'localhost';
// Required for babel-preset-react-app
process.env.NODE_ENV = 'development';
module.exports = {
// Environment mode
mode: 'development',
// Entry point of app
entry: resolveAppPath('src'),
output: {
// Development filename output
filename: 'static/js/bundle.js',
},
devServer: {
// Serve index.html as the base
// Enable compression
compress: true,
// Enable hot reloading
hot: true,
host,
port: 8080,
},
plugins: [
// Re-generate index.html with injected script tag.
// The injected script tag contains a src value of the
// filename output defined above.
new HtmlWebpackPlugin({
inject: true,
template: resolveAppPath('public/index.html'),
}),
],
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
],
},
}