1. Module bundling added to reduce server calls as each file was taking ~440 ms to load on public server.\n2. JavaScript lib files refactored with OOP for use with module bundling.
This commit is contained in:
41
webpack.config.js
Normal file
41
webpack.config.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const path = require('path');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
main: [
|
||||
path.resolve(__dirname, 'static/js/app.js'),
|
||||
path.resolve(__dirname, 'static/css/main.css')
|
||||
]
|
||||
},
|
||||
output: {
|
||||
filename: 'js/[name].bundle.js',
|
||||
path: path.resolve(__dirname, 'static/dist'),
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
'css-loader',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: path.resolve(__dirname, 'templates'), // Exclude templates folder
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'css/[name].css',
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
extensions: ['.js', '.json', '.wasm']
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user