Remember once webpack issue packed

Remember once webpack issue packed

Open in webpack packaged in a webpack-bundle-analyzer, we found a chunk: TinyMCE
a

Find Throughout the project, the only one of the components have not been used in the following code:

import Tinymce from '@/components/Tinymce

After deleting Tinymce folder, project error occurred:

Can't resolve '@/components/Tinymce'

Start troubleshooting an error, then gradually commented code in main.js, and finally to comment out the following code when no longer being given

import router from "./router";

Find the router again the following documents, without the introduction of a continuing investigation, the following code commented out when a good time

const _import = require('./_import_' + process.env.NODE_ENV);

The main function of this line of code above is to use different according to the environment is introduced in the environment without using webpack dev segmentation scheme generates segmentation routing environment:

// development
module.exports = file => require('@/views/' + file + '.vue').default
// production
module.exports = file => () => import('@/views/' + file + '.vue')

The problem lies here require and import, when the content of the imported contain expressions interpretation webpack documents:
A context the Created IF your IS Request the contains Expressions, at The Exact Module IS SO not the compile Known ON Time Module IS Generated context. . It contains references to all modules in
that directory that can be required with a request matching the regular expression. That income vue file "/ @ / views" in (including subdirectories) are require webpack's because views the components include a folder folder, tinymce in this document, will be introduced.

So coming here, there will be a solution to the problem is to use separate pages of a folder to store all the pages corresponding to the route.

Now look webpack version, or 2.6.1, advantages too far behind the upgrade.

Guess you like

Origin www.cnblogs.com/walkermag/p/ji-yi-ciwebpack-da-bao-de-wen-ti.html