47 lines
1,003 B
JavaScript
47 lines
1,003 B
JavaScript
|
const path = require('path');
|
||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||
|
|
||
|
module.exports = {
|
||
|
entry: './src/example.js',
|
||
|
output: {
|
||
|
filename: 'main.js',
|
||
|
path: path.resolve(__dirname, 'dist'),
|
||
|
},
|
||
|
plugins: [
|
||
|
new HtmlWebpackPlugin({
|
||
|
template: './src/example.html',
|
||
|
filename: path.resolve(__dirname, 'dist', 'example.html'),
|
||
|
}),
|
||
|
new MiniCssExtractPlugin({
|
||
|
filename: '[name].css',
|
||
|
chunkFilename: '[id].css',
|
||
|
}),
|
||
|
],
|
||
|
module: {
|
||
|
rules: [
|
||
|
{
|
||
|
test: /\.(js|jsx)$/,
|
||
|
exclude: /node_modules/,
|
||
|
use: {
|
||
|
loader: 'babel-loader',
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
test: /\.css$/,
|
||
|
use: [
|
||
|
{
|
||
|
loader: MiniCssExtractPlugin.loader,
|
||
|
},
|
||
|
'css-loader',
|
||
|
],
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
devServer: {
|
||
|
contentBase: path.join(__dirname, 'dist'),
|
||
|
port: 9000,
|
||
|
historyApiFallback: true,
|
||
|
},
|
||
|
};
|