Created
April 5, 2021 19:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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