@Jun1801

Почему Vue.js не собирается в productions версию?

package.json:
"build-prod": "webpack --colors -p --mode production --config webpack.config.js",


webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");

module.exports = {
    mode: 'production',
    entry: [
        './src/main.js',
        './src/common/styles/index.scss'
    ],
    output: {
        path: path.resolve(__dirname, 'dist_prod'),
        filename: 'bundle.js',
        publicPath: "/"
    },
    resolve: {
        alias: {
            vue: 'vue/dist/vue.js'
        },
    },
    module: {
        rules: [{
            test: /\.(html)$/,
            include: path.resolve(__dirname, 'src'),
            use: {
                loader: 'html-loader',
                options: {
                    minimize: true,
                    removeComments: true,
                    collapseWhitespace: true
                }
            },
        }, {
            test: /\.(png|jpg|ttf|otf|svg)$/,
            include: path.resolve(__dirname, 'src'),
            use: {
                loader: 'file-loader',
                options: {
                    name: '[path][name].[ext]',
                    outputPath: 'loadable/'
                }
            }
        }, {
            test: /\.js$/,
            include: path.resolve(__dirname, 'src'),
            use: {
                loader: 'babel-loader',
                options: {
                    presets: 'env',
                    plugins: [
                        'transform-vue-jsx',
                        'babel-plugin-syntax-dynamic-import'
                    ]
                }
            }
        }, {
            test: /\.(sass|scss)$/,
            include: path.resolve(__dirname, 'src'),
            use: ExtractTextPlugin.extract({
                use: [{
                    loader: "css-loader",
                    options: {
                        sourceMap: false,
                        minimize: true
                    }
                }, {
                    loader: "sass-loader",
                    options: {
                        sourceMap: false,
                        minimize: true
                    }
                }]
            })
        }]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: 'src/index.html',
            minify: true
        }),
        new CopyWebpackPlugin([{
            from: './src/loadable',
            to: './loadable'
        }]),
        new ExtractTextPlugin({
            filename: 'bundle.css',
            allChunks: true,
        })
    ]
};


Сборка проходит успешно, без ошибок, но версия Vue все равно dev.
В консоли браузера: 5c20cd28379bd532792943.pngКак правильно собрать прод версию?
  • Вопрос задан
  • 234 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы