Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The order of connecting several files at one entry point

Tags:

webpack

In the generated js file, the files are not glued in the order they are transferred in the array.

How to correctly specify the order of files connection??

const path = require('path');

module.exports = {
    context: path.join(__dirname, "/public/src/js/entry/"),
    entry: {
        base: [
            './js/lib/jquery/jquery-1.11.1.min.js',
            './js/lib/jquery/jquery-migrate-1.2.1.min.js',
            './js/lib/jquery/jquery.placeholder.min.js,' +
            './js/base/subscribe-mailing.js'
        ],
        indexPage: './indexPage.entry.js',
    },
    output: {
        path: path.resolve(__dirname, 'public/dist/js'),
        filename: '[name].js',
        publicPath: "public/dist/js"
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: '/node_modules/'
            },
            {
                test: /\.css$/,
                use: [
                    'babel-loader',
                    'css-loader'
                ]
            }
        ]
    },

};

as a result, I need a single file with the connected ones in the order in which they are passed in the array

like image 881
Lutogin Andrey Avatar asked Oct 12 '25 11:10

Lutogin Andrey


1 Answers

Not everyone uses React... I needed to Minify CSS/JS files myself in my old projects. Solution it's easy, just in webpack.config.js:

  optimization: {
    moduleIds: 'natural'
  }

The order will be as specified in entry index.js The other useful settings here https://webpack.js.org/configuration/optimization/#optimizationmoduleids

like image 165
Vyacheslav K. Avatar answered Oct 16 '25 07:10

Vyacheslav K.