entria-fullstack icon indicating copy to clipboard operation
entria-fullstack copied to clipboard

implement webpack dll

Open sibelius opened this issue 4 years ago • 1 comments

  • [ ] create one bundle with all node_modules
  • [ ] consume in the main package

for web package https://github.com/entria/entria-fullstack/tree/master/packages/web

sibelius avatar Mar 13 '20 20:03 sibelius

@sibelius

I hope it helps

//plugins.js
    new webpack.DllReferencePlugin({
      manifest: require(path.join(PATHS.ROOT_DIR, 'build/dll/vendors.json')),
    }),

// ###########################################################

// webpack.dll.config.js
const webpack = require('webpack');
const { PATHS, VENDORS_LIST } = require('./shared/constants');

const dllConfig = () => {
  const isProduction = process.env.NODE_ENV === 'production';
  return {
    context: PATHS.ROOT_DIR,
    entry: {
      vendors: VENDORS_LIST,
    },
    output: {
      library: '[name]',
      path: PATHS.STATIC_DLL,
      filename: isProduction ? '[name].[contenthash].dll.js' : '[name].dll.js',
    },
    mode: isProduction ? 'production' : 'development',
    plugins: [
      new webpack.DllPlugin({
        name: '[name]',
        path: 'build/dll/[name].json',
      }),
    ],
  };
};

module.exports = dllConfig;
// ###########################################################

"scripts": {
    "prestart": "rimraf build && NODE_ENV=development webpack --config scripts/webpack/webpack.dll.config.js",
    "start": "NODE_ENV=development webpack-dev-server --config scripts/webpack/webpack.config.js --progress",
    "predev": "rimraf build && NODE_ENV=development webpack --config scripts/webpack/webpack.dll.config.js",
    "dev": "NODE_ENV=development webpack --config scripts/webpack/webpack.config.js --progress",
    "prebuild": "rimraf build && NODE_ENV=production webpack --config scripts/webpack/webpack.dll.config.js",
    "build": " NODE_ENV=production webpack --config scripts/webpack/webpack.config.js",

mauriciord avatar Mar 13 '20 22:03 mauriciord