Skip to content

Commit

Permalink
build(angular): update webpack config to support webpack 5 the defaul…
Browse files Browse the repository at this point in the history
…t in angular 12
  • Loading branch information
jordanpowell88 committed Feb 7, 2022
1 parent 9573e6c commit acd944d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 224 deletions.
File renamed without changes.
134 changes: 0 additions & 134 deletions npm/angular/cypress/plugins/cy-ts-preprocessor.ts

This file was deleted.

171 changes: 84 additions & 87 deletions npm/angular/cypress/plugins/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as webpack from 'webpack'
import * as path from 'path'
import { AngularWebpackPlugin } from '@ngtools/webpack'

module.exports = {
mode: 'development',
Expand All @@ -11,30 +11,36 @@ module.exports = {
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
},
{
test: /\.ts$/,
// loaders: ['ts-loader', 'angular2-template-loader'],
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
{
loader: 'angular2-template-loader',
},
],
exclude: [/node_modules/, /test.ts/, /polyfills.ts/],
test: /\.[jt]sx?$/,
loader: '@ngtools/webpack',
},
// {
// enforce: 'pre',
// test: /\.js$/,
// use: 'source-map-loader',
// },
// {
// test: /\.ts$/,
// // loaders: ['ts-loader', 'angular2-template-loader'],
// use: [
// {
// loader: 'ts-loader',
// options: {
// transpileOnly: true,
// },
// },
// {
// loader: 'angular2-template-loader',
// },
// ],
// exclude: [/node_modules/, /test.ts/, /polyfills.ts/],
// },
{
test: /\.(js|ts)$/,
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
},
enforce: 'post',
include: path.join(__dirname, '../..', 'src'),
exclude: [
Expand All @@ -43,74 +49,65 @@ module.exports = {
/(ngfactory|ngstyle)\.js/,
],
},
{
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
// Removing this will cause deprecation warnings to appear.
test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
parser: { system: true },
},
{
test: /\.css$/,
loader: 'raw-loader',
},
{
test: /(\.scss|\.sass)$/,
use: ['raw-loader', 'sass-loader'],
},
{
test: /\.html$/,
loader: 'raw-loader',
exclude: [path.join(__dirname, '../../src/index.html')],
},
{
test: /\.(jpe?g|png|gif)$/i,
loader: 'file-loader?name=assets/images/[name].[ext]',
},
{
test: /\.(mp4|webm|ogg)$/i,
loader: 'file-loader?name=assets/videos/[name].[ext]',
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader:
'file-loader?limit=10000&mimetype=image/svg+xml&name=assets/svgs/[name].[ext]',
},
{
test: /\.eot(\?v=\d+.\d+.\d+)?$/,
loader:
'file-loader?prefix=font/&limit=5000&name=assets/fonts/[name].[ext]',
},
{
test: /\.(woff|woff2)$/,
loader:
'file-loader?prefix=font/&limit=5000&name=assets/fonts/[name].[ext]',
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader:
'file-loader?limit=10000&mimetype=application/octet-stream&name=assets/fonts/[name].[ext]',
},
// {
// // Mark files inside `@angular/core` as using SystemJS style dynamic imports.
// // Removing this will cause deprecation warnings to appear.
// test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
// parser: { system: true },
// },
// {
// test: /\.css$/,
// use: 'raw-loader',
// },
// {
// test: /(\.scss|\.sass)$/,
// use: ['raw-loader', 'sass-loader'],
// },
// {
// test: /\.html$/,
// use: 'raw-loader',
// exclude: [path.join(__dirname, '../../src/index.html')],
// },
// {
// test: /\.(jpe?g|png|gif)$/i,
// use: 'file-loader?name=assets/images/[name].[ext]',
// },
// {
// test: /\.(mp4|webm|ogg)$/i,
// use: 'file-loader?name=assets/videos/[name].[ext]',
// },
// {
// test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
// use:
// 'file-loader?limit=10000&mimetype=image/svg+xml&name=assets/svgs/[name].[ext]',
// },
// {
// test: /\.eot(\?v=\d+.\d+.\d+)?$/,
// use:
// 'file-loader?prefix=font/&limit=5000&name=assets/fonts/[name].[ext]',
// },
// {
// test: /\.(woff|woff2)$/,
// use:
// 'file-loader?prefix=font/&limit=5000&name=assets/fonts/[name].[ext]',
// },
// {
// test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
// use:
// 'file-loader?limit=10000&mimetype=application/octet-stream&name=assets/fonts/[name].[ext]',
// },
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'test'),
// new webpack.DefinePlugin({
// 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'test'),
// }),
// new webpack.ContextReplacementPlugin(
// /\@angular(\\|\/)core(\\|\/)f?esm5/,
// path.join(__dirname, './src'),
// ),
new AngularWebpackPlugin({
tsconfig: 'tsconfig.json',
}),
new webpack.ContextReplacementPlugin(
/\@angular(\\|\/)core(\\|\/)f?esm5/,
path.join(__dirname, './src'),
),
],
performance: {
hints: false,
},
node: {
global: true,
crypto: 'empty',
process: false,
module: false,
clearImmediate: false,
setImmediate: false,
fs: 'empty',
},
}
5 changes: 3 additions & 2 deletions npm/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@cypress/code-coverage": "3.9.5",
"@cypress/webpack-dev-server": "0.0.0-development",
"@cypress/webpack-preprocessor": "5.7.0",
"@ngtools/webpack": "12.2.16",
"@types/cypress-image-snapshot": "3.1.5",
"@types/node": "8.10.66",
"angular-router-loader": "0.8.5",
Expand All @@ -63,7 +64,7 @@
"tslib": "^2.2.0",
"tslint": "6.1.3",
"typescript": "4.2.4",
"webpack-dev-server": "4.0.0",
"webpack-dev-server": "4.7.4",
"zone.js": "~0.11.4"
},
"peerDependencies": {
Expand All @@ -88,4 +89,4 @@
"social": "@LeJeanbono"
}
]
}
}
3 changes: 2 additions & 1 deletion npm/angular/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"outDir": "./out-tsc/spec",
"types": [
"jasmine",
"node"
"node",
"cypress"
]
},
"files": [
Expand Down

0 comments on commit acd944d

Please sign in to comment.