Skip to content

Instantly share code, notes, and snippets.

@adityanaag3
Created April 5, 2021 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityanaag3/f23a88d43680483b9c3c4cc5dd8c5b6c to your computer and use it in GitHub Desktop.
Save adityanaag3/f23a88d43680483b9c3c4cc5dd8c5b6c to your computer and use it in GitHub Desktop.
A fully custom webpack config file for a multi page LWC OSS app
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LwcWebpackPlugin = require('lwc-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
entry: {
index: './src/index.js',
about: './src/about.js'
},
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].bundle.[contenthash].js',
publicPath: '/'
},
plugins: [
new CleanWebpackPlugin(),
new LwcWebpackPlugin(),
new HtmlWebpackPlugin({
template: './src/about.html',
filename: 'about/index.html',
chunks: ['about']
}),
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index-new.html',
chunks: ['index']
}),
new CopyPlugin({
patterns: [
{ from: 'src/resources/', to: 'resources/' }
]
})
],
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
]
}
]
},
stats: 'errors-only'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment