J
J
Jun18012018-12-24 15:13:09
webpack
Jun1801, 2018-12-24 15:13:09

Why isn't Vue.js going to 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,
        })
    ]
};

The build succeeds with no errors, but the Vue version is still dev.
In the browser console: 5c20cd28379bd532792943.pngHow to properly build the prod version?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question