Skip to content

vue Build multi-page CSS load redundant #4819

@davedat

Description

@davedat

Version

4.0.5

Reproduction link

http://127.0.0.1:8080/#/

Environment info

{
  "name": "html",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "babel-polyfill": "^6.26.0",
    "core-js": "^3.3.2",
    "view-design": "^4.0.2",
    "vue": "^2.6.10",
    "vue-router": "^3.1.3",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.0.0",
    "@vue/cli-plugin-router": "^4.0.0",
    "@vue/cli-plugin-vuex": "^4.0.0",
    "@vue/cli-service": "^4.0.0",
    "vue-template-compiler": "^2.6.10"
  }
}

Steps to reproduce

// vue.config.js

module.exports = {
  outputDir:"../src/main/resources/static/",
  pages: { 
    admin: {
      entry: 'src/main.js',
      template: 'public/index.html',
      filename: 'index.html',
      title: 'admin'
    },
    mobile: {
      entry: 'src/mobile.js',
      template: 'public/mobile.html',
      filename: 'mobile.html',
      title: 'mobile',
    }
  }
}

// src/main.js

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import ViewUI from 'view-design'

/*** this iview.css will appear in bundle file  mobile.html  why?  i just want it in index.html ***/
import 'view-design/dist/styles/iview.css'

import 'babel-polyfill'

Vue.use(ViewUI);

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

// src/mobile.js

import Vue from 'vue'
import App from './App.vue'
import router from './router/mobile'
import store from './store/mobile'

/****  here have no css file import ****/

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

What is expected?

bundle file mobile.html have no css iview.css import

What is actually happening?

bundle file mobile.html have css iview.css import
i just want it in index.html

when i run npm run serve it working
but npm run build
how to fix it ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions