Demonstrate a simple Webpack setup (#5185)

This commit is contained in:
Shaun Luttin
2020-06-15 11:20:08 -07:00
committed by GitHub
parent f3b253af1c
commit 75a2b9a5cc
8 changed files with 6957 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const outputPath = path.resolve(__dirname, 'dist');
module.exports = {
mode: 'development',
entry: {
app: './src/index.js',
},
module: {
rules: [
{
test: /\.yaml$/,
use: [
{ loader: 'json-loader' },
{ loader: 'yaml-loader' }
]
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
]
}
]
},
plugins: [
new CleanWebpackPlugin([
outputPath
]),
new CopyWebpackPlugin([
{
// Copy the Swagger OAuth2 redirect file to the project root;
// that file handles the OAuth2 redirect after authenticating the end-user.
from: 'node_modules/swagger-ui/dist/oauth2-redirect.html',
to: './'
}
]),
new HtmlWebpackPlugin({
template: 'index.html'
})
],
output: {
filename: '[name].bundle.js',
path: outputPath,
}
};