/*
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @Author: liusheng
 * @Date: 2022-03-24 10:56:26
 */
const path = require("path");
const webpack = require("webpack");
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;

module.exports = {
    devtool: 'source-map',
    entry: "./src/index.js", //入口文件，就是上步骤的src目录下的index.js文件，
    output: {
        path: path.resolve(__dirname, './dist'), //输出路径，就是上步骤中新建的dist目录，
        publicPath: '/dist/',
        filename: 'tj-component-vue.min.js',
        libraryTarget: 'umd',
        umdNamedDefine: true
    },
    node: {
        fs: 'empty',
        net: 'empty'
    },
    externals: {
        vue: "vue",
        axios: "axios"
    },
    module: {
        rules: [{
                test: /\.vue$/,
                loader: 'vue-loader'
            },
            {
                test: /\.less$/,
                use: [{
                        loader: "style-loader"
                    },
                    {
                        loader: "css-loader"
                    },
                    {
                        loader: "less-loader"
                    }
                ]
            },
            {
                test: /\.scss$/,
                use: [{
                        loader: "style-loader"
                    },
                    {
                        loader: "css-loader"
                    },
                    {
                        loader: "scss-loader"
                    }
                ]
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.(png|jpg|gif|ttf|svg|woff|eot)$/,
                loader: 'url-loader',
                query: {
                    limit: 30000,
                    name: '[name].[ext]?[hash]'
                }
            }
        ]
    },
    plugins: [
        new UglifyJsPlugin({
            exclude: /node_modules\/sm-crypto/,
            uglifyOptions: {
              output: {
                comments: false, // remove all comments
              },
              compress: {
                warnings: false,
                drop_debugger: true
              }
            }
        })
    ]
};