123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- const path = require('path')
- const MiniCssExtractPlugin = require("mini-css-extract-plugin")
- const HtmlWebpackPlugin = require('html-webpack-plugin')
- const projectPath = path.resolve(__dirname, '../')
- module.exports = {
- mode: 'production',
- entry: './src/index.js',
- output: {
- path: path.resolve(__dirname, '../dist'),
- filename: '[name]-bundle-[hash:8].js'
- },
- module: {
- rules: [
- {
- test: /\.js$/,
- loader: 'babel-loader',
- include: path.resolve(projectPath, 'src'),
- exclude: path.resolve(projectPath, "node_modules"),
- },
- {
- test: /\.css$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- options: {
- publicPath: '../build/styles'
- }
- },
- {
- loader: "css-loader",
- options: {
- modules: true,
- camelCase: true,
- localIdentName: '[name]__[local]--[hash:base64:5]'
- }
- }
- ]
- }
- ]
- },
- plugins: [
- new MiniCssExtractPlugin({
- filename: "[name].css",
- chunkFilename: "[id].css"
- }),
- new HtmlWebpackPlugin({
- title: 'CSS Modules Demo',
- filename: 'index.html',
- template: path.resolve(projectPath, 'index.html'),
- inject: false
- })
- ],
- }
|