为了账号安全,请及时绑定邮箱和手机立即绑定

.UglifyJsPlugin 压缩混淆后运行报错,前端用的angularjs,求老师看看

'use strict'

const path = require('path')
const webpack = require('webpack')
const htmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const CopyWebpackPlugin = require("copy-webpack-plugin")

module.exports = {
    entry: {
        app: './src/app.js',
        vendor: [ 'jquery', 'angular', 'angular-ui-router', 'angular-cookies', 'oclazyload', 'angular-md5', 'angular-toastr']
    },
    output: {
        path: path.resolve(__dirname, '../dist/'),
        filename: "js/[name].bandle.js",
        chunkFilename: "[name].bandle.js"
    },
    module: {
        rules:[
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: [
                    path.resolve(__dirname, '../node_modules')
                ],
                include: [
                    path.resolve(__dirname, '../src')
                ],
                query: {
                    presets: ["es2015","stage-0"]
                }
            },
            {
                test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
                loader: "file"
            },
            {
                test: /\.(woff|woff2)$/,
                loader:"url?prefix=font/&limit=5000"
            },
            {
                test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/octet-stream"
            },
            {
                test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=image/svg+xml"
            },
            {
                test: /\.css$/,
                exclude: [
                    path.resolve(__dirname, '../node_modules')
                ],
                use: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: [
                        {
                            loader:  'css-loader',
                        },
                        {
                            loader:  'postcss-loader',
                            options: {
                                plugins: ()=>[
                                    require('autoprefixer')({
                                        broswers: [
                                            'last5versions'
                                        ]
                                    })
                                ]
                            }
                        }
                    ]
                })
            },
            {
                test: /\.html$/,
                use: [
                    {
                        loader: "html-loader"
                    }
                ]
            },
            {
                test: /\.(png|jpe?g|gif|svg)$/i,
                use: [
                    {
                        loader: "url-loader?limit=5120&name=images/[name].[ext]"
                    },
                    {
                        loader: "image-webpack"
                    }
                ]
            }
        ]
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            names: ['vendor', 'manifest'],
        }),
        new ExtractTextPlugin('css/[name].css'),
        new htmlWebpackPlugin({
            template: "./src/index.html",
            filename: "index.html",
            inject: "body",
            title: "引导美真的美",
            minify: {
                removeComments: true,
                collapseWhitespace: true
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false,
                drop_console: true
            },
        }),
        new CopyWebpackPlugin([{
            from: path.resolve(__dirname, '../src/favicon.ico')
        }]),
        new webpack.ProvidePlugin({
            $:"jquery",
            jQuery:"jquery",
            "window.jQuery":"jquery"
        })
    ],
    resolveLoader: {
        moduleExtensions: ['-loader']
    }
}


正在回答

2 回答

混淆以后的报错是什么?

0 回复 有任何疑惑可以回复我~

不压缩,运行就正常

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

.UglifyJsPlugin 压缩混淆后运行报错,前端用的angularjs,求老师看看

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信