Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

webpack 4 upgrade#293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
RezaHaidari wants to merge3 commits intovuejs:master
base:master
Choose a base branch
Loading
fromRezaHaidari:master
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletionsbuild/webpack.base.config.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,17 +56,16 @@ module.exports = {
maxEntrypointSize: 300000,
hints: isProd ? 'warning' : false
},
mode: process.env.NODE_ENV || 'development',
plugins: isProd
? [
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new ExtractTextPlugin({
filename: 'common.[chunkhash].css'
filename: 'common.[chunkhash].css',
allChunks: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why change it?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

"extract-text-webpack-plugin" get error : TypeError: Cannot read property 'call' of undefined
Fixing it, by adding allChunks: true
webpack/webpack#959

Copy link

@asadsahiasadsahiMar 6, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@RezaHaidari I can't see any issues with existing ExtractTextPlugin config. Also following config isn't needed as well I guess as by setting mode to production it minifies the code anyway.

if (isProd) {  config.optimization = {    ...config.optimization,    minimizer: [      new UglifyJsPlugin({        sourceMap: true,        uglifyOptions: {          compress: {            inline: false,          },        },      }),    ],  };}

Any comments?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

})
]
: [
new FriendlyErrorsPlugin()
]
}
}
43 changes: 23 additions & 20 deletionsbuild/webpack.client.config.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,29 +16,32 @@ const config = merge(base, {
plugins: [
// strip dev-only code in Vue source
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env.VUE_ENV': '"client"'
}),
// extract vendor chunks for better caching
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
// a module is extracted into the vendor chunk if...
return (
// it's inside node_modules
/node_modules/.test(module.context) &&
// and not a CSS file (due to extract-text-webpack-plugin limitation)
!/\.css$/.test(module.request)
)
}
}),
// extract webpack runtime & manifest to avoid vendor chunk hash changing
// on every build.
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
}),
new VueSSRClientPlugin()
]
],
optimization:{
runtimeChunk: {
name: "manifest"
},
// extract webpack runtime & manifest to avoid vendor chunk hash changing
// on every build.
// extract vendor chunks for better caching
splitChunks:{
chunks:"initial",
cacheGroups: {
vendors: function (module) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I tried your code using webpack 4.23.1 and it fails with a "TypeError: cacheGroup.getName is not a function"
The correct form for cacheGroups entries seems different (seehttps://webpack.js.org/plugins/split-chunks-plugin/#splitchunks-cachegroups)

  vendors: {    test: function(module) {

// a module is extracted into the vendor chunk if...
return (
// it's inside node_modules
/node_modules/.test(module.context) &&
// and not a CSS file (due to extract-text-webpack-plugin limitation)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

due to extract-text-webpack-plugin limitation

I wondering ifmini-css-extract-plugin has the same limitation ?

!/\.css$/.test(module.request)
)
}
}
}
},
})

if (process.env.NODE_ENV === 'production') {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp