Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Webpack 5 #4083

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
24 changes: 11 additions & 13 deletions installer/templates/phx_assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@
"nprogress": "^0.2.0"<% end %>
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-loader": "^8.0.0",
"copy-webpack-plugin": "^5.1.1",
"css-loader": "^3.4.2",
"sass-loader": "^8.0.2",
"sass": "^1.27.0",
"hard-source-webpack-plugin": "^0.13.1",
"mini-css-extract-plugin": "^0.9.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"terser-webpack-plugin": "^2.3.2",
"webpack": "4.41.5",
"webpack-cli": "^3.3.2"
"@babel/core": "^7.12.0",
"@babel/preset-env": "^7.12.0",
"babel-loader": "^8.2.0",
"copy-webpack-plugin": "^6.3.0",
"css-loader": "^5.0.0",
"css-minimizer-webpack-plugin": "^1.1.5",
"sass-loader": "^10.1.0",
"sass": "^1.29.0",
"mini-css-extract-plugin": "^1.3.0",
"webpack": "^5.8.0",
"webpack-cli": "^4.2.0"
}
}
14 changes: 4 additions & 10 deletions installer/templates/phx_assets/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
const path = require('path');
const glob = require('glob');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = (env, options) => {
const devMode = options.mode !== 'production';

return {
optimization: {
minimizer: [
new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }),
new OptimizeCSSAssetsPlugin({})
]
minimizer: ["...", new CssMinimizerPlugin()]
},
entry: {
'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
Expand Down Expand Up @@ -46,8 +41,7 @@ module.exports = (env, options) => {
},
plugins: [
new MiniCssExtractPlugin({ filename: '../css/[name].css' }),
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
new CopyWebpackPlugin({patterns: [{ from: 'static/', to: '../' }]})
]
.concat(devMode ? [new HardSourceWebpackPlugin()] : [])
}
};
2 changes: 1 addition & 1 deletion installer/templates/phx_single/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ config :<%= @app_name %>, <%= @endpoint_module %>,
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
"--watch",
cd: Path.expand("../assets", __DIR__)
]
]<% else %>[]<% end %>
Expand Down