webpack忽略依賴加載

忽略掉某些依賴的加載

使用webpack內置的ignorePlugin插件

let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');
let webpack = require('webpack');
module.exports = {
    entry: './src/index.js',
    mode:'development',
    module: {
        // noParse: /jquery/,  // 不去解析jquery中的依賴關係,
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                include: path.resolve('./src/'),
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: [
                            '@babel/preset-env',
                            '@babel/preset-react',
                        ]
                    }
                }

            }
        ]
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    plugins: [
        new webpack.IgnorePlugin(/\.\/locale/, /moment/),
        new HtmlWebpackPlugin({
            template: './public/index.html',
            filename: 'index.html',
        })
    ]
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章