G
G
Gip2019-06-14 10:02:15
webpack
Gip, 2019-06-14 10:02:15

How to make two mix-manifest.json?

I collect resources for two sites with one yarn command. In webpack.mix.js, the config is something like this:

const mixCommon = require('laravel-mix');
const mixLanding = require('laravel-mix');

//Конфиг для основного сайта ----------------------------------------------------------------------
mixCommon.sass('frontend/assets/src/sass/common.scss', 'frontend/web/css')
  .options({
    imgLoaderOptions: {enabled: false},
    postCss: [
      require('postcss-css-variables')()
    ]
  })
  .version();

mixCommon.setPublicPath('frontend/web/');

//Тут собираем файлы для лэндинга -------------------------------------------------------------
mixLanding.sass('landing/assets/src/sass/landing.scss', 'landing/web/css')
  .options({
    imgLoaderOptions: {enabled: false},
    postCss: [
      require('postcss-css-variables')()
    ]
  })
  .version();

mixLanding.setPublicPath('landing/web/');

the problem is that the second mix-manifest.json, which is created in landing/web/, also contains records about common resources. Can you tell me how to share it correctly? I do not get you. Only split into two teams? In principle, it does not ask to eat, because. further, the asset manager still publishes only what is needed for everyone, but somehow it is an eyesore.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gip, 2019-06-21
@Giperoglif

In general, yes. Only division into two teams.
In package.json:

"scripts": {
    "production-front": "cross-env process.env.section=front NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production-admin": "cross-env process.env.section=admin NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },

in webpack.min.js:
let mix = require('laravel-mix');

if (process.env.section) {
  require(__dirname + '/webpack.mix.' + process.env.section + '.js');
}

well, two files:
webpack.mix.front.jsandwebpack.mix.admin.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question