Webpack4 configuration Public JS and CSS are not packaged, only do separate compression
there are common.js and env.js, as well as base.scss coming in through require. There is also a Jquery
HtmlWebpackPlugin
1.common.jsenv.jsJSbase.scsscss
2.JSJquery
3. Is there any way to package public files separately, Jquery and common,env separately, and base
first of all, the configuration you posted is not to extract jquery
at all, but to extract all js
files and type them into packages called jquery
.
cacheGroups: {
common: {
//
test: path.resolve(__dirname, '../src/assets/js/common'),
name: "commmon-test",
chunks: "all",
enforce: true
}
}
Packages under
node_modules
can be configured in this way. By the same token, if your
jquery
is installed through
npm
, I can't try to extract it. The style file is the same, but there is a problem with the style file. Although
webpack
everything is a module, the style file is still logically extracted
from js
, generating
base.css
at the same time, there will be an extra
base.js
file (basically empty).
is also the answer that has been answered under another answer. Packages like jquery can be introduced directly into html, using cdn (or other paths). In webpack, you can solve the introduction by configuring externals
.
is a direct separation of js files
here is a webpack4 example, you can check https://github.com/crlang/eas..
vendor configuration item for js separate package
css separate package extract-text-webpack-plugin