Closed JoelParke closed 6 years ago
@JoelParke how are you importing font-awesome
I should have mentioned that to get the above working, I needed to add '"less-loader": "^1.0.0",' to my package.json. (which settles into 4.1.0)
For font-awesome, I have:
"font-awesome": "^4.7.0",
"font-awesome-webpack": "0.0.5-beta.2",
When working for webpack 3, these are the same, but without less-loader, which is not needed.
For consistency, I added less-loader: ^4.1.0, into the webpack 3 build, nothing changes.
I dug a bit deeper, and there is an issue with the dependencies from font-awesome-webpack -- which seems a bit abandoned. But someone did a fork, and updated the dependencies.
When I did:
yarn add font-awesome-webpack@https://github.com/jarecsni/font-awesome-webpack#440af2a2efe7ba1779d039556f04538e57bad4bb --dev
All works as expected - with expected warnings... So I am back working away.
Thanks for looking at this, and I am hoping that this will help others upgrading to webpack 4.
@JoelParke Hey, Im also struggling with running angular-starter with webpack 4. Could you please share your webpack config files and maybe your package.json file so I could see what I'm doing wrong? Thanks in advance.
Here are the changes etc...
For config/webpack.prod.js
Remove:
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
and replace with:
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin');
And, change:
/**
* Extract CSS files from .src/styles directory to external CSS file
*/
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
}),
include: [helpers.root('src', 'styles')]
},
/**
* Extract and compile SCSS files from .src/styles directory to external CSS file
*/
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!sass-loader'
}),
include: [helpers.root('src', 'styles')]
},
TO
/**
* Extract CSS files from .src/styles directory to external CSS file
*/
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
include: [helpers.root('src', 'styles')]
},
/**
* Extract and compile SCSS files from .src/styles directory to external CSS file
*/
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
include: [helpers.root('src', 'styles')]
},
And Replace:
/**
* Plugin: ExtractTextPlugin
* Description: Extracts imported CSS files into external stylesheet
*
* See: https://github.com/webpack/extract-text-webpack-plugin
*/
new ExtractTextPlugin('[name].[contenthash].css'),
With:
new MiniCssExtractPlugin({
filename: '[name]-[hash].css',
chunkFilename: '[name]-[chunkhash].css'}),
And in UglifyJsPlugin() you can set
sourceMap: false
Which will speed up the builds tremendously.
I will attach my package.json, and yarn.lock.
NOTE: you can update all the packages, EXCEPT! rxjs - as they have some breaking changes!
ALSO if you are using font-awsesome-webpack, please see the issue with webpack4 and fix earlier.
packages.tar.gz
Let me know how it goes. I have enabled the compression, but I noticed that if I delete the existing files, then index.html cannot be found, and I it unclear to me how much the compression saves on loading.
I would be curious what your experience is.
Thanks,
@JoelParke Thanks a lot mate! Tried it out and it seems to be working well. Also thanks for the sourceMap tip ;)
We have no problems whatsoever with font-awesome and Webpack 4 with latest versions of plugins... I supposed the issues described here were fixed, so no need for workarounds anymore. Closing this one.
I am getting this:
`WARNING in ./node_modules/@angular/core/esm5/core.js
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
@ ./src/environments/environment.ts 6570:15-36 2:0-47 4:0-14
@ ./src/main.browser.ts
I tried to ignore the error with a stats: {} configuration but it still spills out all over. It is telling the truth, that files does contain System.import even in the latest Angular 6.0.9. I wish we could force webpack to use the other module formats. Can we?
I believe you can safely ignore it. This is something that Angular team will have to handle eventually.
Note: for support questions, please use one of these channels: Chat: AngularClass.slack or Twitter: @TipeIO
What is the current behavior? the webpack4 branch can be made to build, when I shift to MiniCssExtractPlugin() from ExtractTextPlugin(). This works fairly well. Basically: I added:
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); /**
Extract CSS files from .src/styles directory to external CSS file */ { test: /.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], include: [helpers.root('src', 'styles')] },
/**
And I replaced new ExtractTextPlugin(....) with:
I also updated all the packages to the latest versions - on 4-22.
I have a large project built around angular-starter, which works great with webpack 3. But with webpack4, even with the changes above, I get killed late in the build
` SO it seems that font-awesome is killing the build for webpack 4. Any thoughts as to why this might be, would be very helpful. I would like to experiment with some strategies to split chunks, but until I can get it running in production, it seems somewhat pointless.