123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- const CleanWebpackPlugin = require('clean-webpack-plugin')
- const { HTMLWebpackPlugins, entry } = require('./_build/genMultiEntry.js')
- const webpack = require('webpack')
- const path = require('path')
- module.exports = {
- entry: entry,
- output: {
- filename: 'js/[name]_[hash:5].js',
- chunkFilename: 'js/[name]_[contenthash:5].js'
- },
- resolve: {
- alias: {
- '@': path.resolve(__dirname, 'src')
- }
- },
- optimization: {
- splitChunks: {
- chunks: 'all',
- cacheGroups: {
- commons: {
- test: /[\\/]node_modules[\\/]/,
- priority: -10,
- name: 'commons'
- }
- }
- }
- },
- module: {
- rules: [
- {
- test: /\.js$/,
- exclude: /node_modules/,
- use: [
- 'babel-loader',
- {
- loader: 'eslint-loader',
- options: {
- fix: true
- }
- }
- ]
- },
- {
- test: /\.html$/,
- use: {
- loader: 'html-loader',
- options: {
- attrs: [':src']
- }
- }
- },
- {
- test: /\.(svg|jpe?g|gif|png|bmp)$/,
- use: {
- loader: 'url-loader',
- options: {
- name: '[name]_[hash:5].[ext]',
- outputPath: 'images',
- limit: 10240
- }
- }
- },
- {
- test: /\.(eot|ttf|woff2?|otf)$/,
- use: {
- loader: 'file-loader',
- options: {
- name: '[name]_[hash:5].[ext]',
- outputPath: 'fonts'
- }
- }
- }
- ]
- },
- plugins: [
- ...HTMLWebpackPlugins,
- new webpack.ProvidePlugin({
- $: 'jquery',
- jQuery: 'jquery'
- }),
- new CleanWebpackPlugin()
- ]
- }
|