webpack.base.config.js:
entry: {
app: "./src/index.js"
},
output: {
path: config.build.assetsRoot, // "/"
publicPath: config.dev.assetsPublicPath, // "static"
filename: "[name].bundle.js",
chunkFilename: "[name].chunk.js"
},
router (you can get name): correctly by using require.ensure
const routes = [
{
path: "/",
component: r => {
require.ensure([], () => r(require("./view/index/index.vue")), "index")
}
},
{
path: "/errorPage",
component: r => {
require.ensure([], () => r(require("./view/errorPage/errorPage.vue")), "errorPage")
}
},
{
path: "/page",
component: r => {
require.ensure([], () => r(require("./view/page/page.vue")), "page")
}
}
];
result (get name): correctly
import:
name:
some people say it has something to do with the babel setting, but it doesn"t work if I try:
.babelrc:
{
"env": {
"production": {
"presets": [
["env", {
"targets": {
"browsers": ["last 2 version", "ie 10"]
},
"modules": false,
"debug": true
}]
],
"plugins": [
"transform-runtime",
"transform-object-rest-spread",
"dynamic-import-webpack"
]
},
"development": {
"presets": [
["env", {
"targets": {
"chrome": 60
},
"modules": false,
"debug": true
}]
],
"plugins": [
"transform-object-rest-spread",
"dynamic-import-webpack"
]
}
}
}
solve the problem with all the bigwigs