R
R
Ruslan Absalyamov2019-03-21 11:25:13
webpack
Ruslan Absalyamov, 2019-03-21 11:25:13

Why is my webpack incorrectly pointing to compiled files?

I'm getting an error

build.js:1 GET http://127.0.0.1:8081/dist2.build.js net::ERR_ABORTED 404 (Not Found)
build.js:12 [Vue warn]: Failed to resolve async component: ()=>n.e(2).then(n.bind(null,339))
Reason: Error: Loading chunk 2 failed.

The only problem is that I only have the /dist/2.build.js file. And it merges the directory and it turns out dist2.build.js/ But this file does not exist. I don’t understand where you need to change webpack so that it forms the path normally
All webpack settings
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');

const config = {
    entry: './src/main.js',
    output: {
        path: path.resolve(__dirname, "dist"),
        publicPath: "dist",
        filename: "build.js"
    },
    module: {
        rules: [
            {
                test: /\.vue$/,
                use: 'vue-loader'
            },
            {
                test: /\.css$/,
                use: [
                    { loader: "style-loader" },
                    { loader: "css-loader" }
                ]
            },
            {
                test: /\.scss$/,
                use: [
                    { loader: "style-loader" },
                    { loader: "css-loader" },
                    { loader: "sass-loader" }
                ]
            },
            {
                test: /\.svg$/,
                loader: 'vue-svg-loader',
            }
        ]
    },
    resolve: {
        alias: {
            vue: 'vue/dist/vue.js',
            '@': path.join(__dirname, 'src/'),
        }
    },

    plugins: [
        new VueLoaderPlugin()
    ],
};

module.exports = (env, argv) => {
    if (argv.mode !== "production") {
        config.mode = "development";
        config.devtool = 'source-map';
        config.watch = true;
        config.devServer = { contentBase: __dirname + '/' }
    }
    return config;
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Absalyamov, 2019-03-21
@rusline18

I found my cant why these files were accessed this way. It was necessary to put publicPath not "dist" but "dist/"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question