How to break application and provider code with Webpack

I am starting a new project with responsiveness So I have this webpack.config.jsfile that should mask 2 pieces, one for the application code and one for the provider based on this example from the webpack documentation

webpack.config.js

const webpack = require('webpack');
module.exports = {
    entry: {
        app: './src/App.jsx',
        vendor: ['react', 'react-dom', 'whatwg-fetch']
    },
    output: {
        path: __dirname + './static/',
        filename: 'app.bundle.js'
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            filename: 'vendor.bundle.js'
        })
    ],
    module: {
        loaders: [{
            test: /.jsx$/,
            loader: 'babel-loader',
            query: {
                presets: ['react', 'es2015']
            }
        }, ]
    }
};

When I start webpack -p, I see that my two assets should be generated, but there is nothing in the output directory.

Webpack exit

           Asset    Size  Chunks             Chunk Names
   app.bundle.js    6 kB       0  [emitted]  app
vendor.bundle.js  108 kB       1  [emitted]  vendor
   [6] ./src/App.jsx 3.37 kB {0} [built]
   [7] ./src/IssueAdd.jsx 3.57 kB {0} [built]
   [9] ./src/IssueList.jsx 5.46 kB {0} [built]
  [10] ./src/IssueFilter.jsx 2.52 kB {0} [built]
  [20] multi react react-dom whatwg-fetch 52 bytes {1} [built]
    + 16 hidden modules

Webpack version is 3.8.1 with Windows 7 dev environment. Did I miss something?

+4
source share
1 answer

, , , , , - [chunkhash], webpack 3.8.1

, - ( ):

 var path = require('path');

 output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].[chunkhash].js'
  },

plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor'
    }) 
]

Webpack 3.8.1 output-filename

+4

Source: https://habr.com/ru/post/1689324/


All Articles