Skip to content

Commit 2f65c88

Browse files
committed
Eliminate the requisite for copying config files
Split webpack config files into "base", "dev" and "prod" parts. Update package.json for Angular apps so it has two build commands, for development and production packaging, thus removing the need for manually copying config files when switching between "dev" and "prod" builds. Fix development config file so webpack now generates source map files in bundled application. Update the documentation.
1 parent 9a3503b commit 2f65c88

File tree

25 files changed

+27413
-32699
lines changed

25 files changed

+27413
-32699
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This project provides tools and shows you an easy way to integrate one or more A
55
## Getting Started
66

77
After you clone the code you have to build the apps by running necessary commands, than you can test from the default Laravel welcome page.
8-
You will see links that will take you to separate integrated Angular apps.
8+
You will see links that will take you to the separate integrated Angular apps.
99

10-
Two links will take you to separate Angular bundled apps made using **angular-cli**.
10+
Two links will take you to the separate Angular bundled apps made using **angular-cli**.
1111

1212
All Angular apps live in `angular` directory in Laravel project root directory and they are bundled and distributed to `public` directory after build.
1313

14-
### Setting Up
14+
## Setting Up
1515

1616
Clone code, **cd** to project directory and use composer to install all the dependencies.
1717

@@ -25,7 +25,7 @@ Follow the link below to get detailed explanation on how to integrate Angular pr
2525

2626
+ [Laravel - Angular integration](docs/angular/integration.md)
2727

28-
### Note
28+
## Note
2929

3030
This project no longer supports SistemJS build as it is outdated by now. Developing Angular projects without using **angular-cli** tool doesn't make much sense that is why this project now only focuses on integrating Angular programs made with **angular-cli** into Laravel.
3131

angular/app1/base.config.js

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const CopyWebpackPlugin = require('copy-webpack-plugin');
4+
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
5+
const CircularDependencyPlugin = require('circular-dependency-plugin');
6+
const rxPaths = require('rxjs/_esm5/path-mapping');
7+
8+
const { NoEmitOnErrorsPlugin } = require('webpack');
9+
const { BaseHrefWebpackPlugin } = require('@angular/cli/plugins/webpack');
10+
const { CommonsChunkPlugin } = require('webpack').optimize;
11+
12+
const nodeModules = path.join(process.cwd(), 'node_modules');
13+
const realNodeModules = fs.realpathSync(nodeModules);
14+
const genDirNodeModules = path.join(process.cwd(), 'src', '$$_gendir', 'node_modules');
15+
16+
const projectRoot = process.cwd();
17+
18+
module.exports = {
19+
"resolve": {
20+
"extensions": [
21+
".ts",
22+
".js"
23+
],
24+
"symlinks": true,
25+
"modules": [
26+
"./src",
27+
"./node_modules"
28+
]
29+
},
30+
"resolveLoader": {
31+
"modules": [
32+
"./node_modules"
33+
],
34+
"alias": rxPaths()
35+
},
36+
"module": {
37+
"rules": [
38+
{
39+
"test": /\.html$/,
40+
"loader": "raw-loader"
41+
},
42+
{
43+
"test": /\.(eot|svg|cur)$/,
44+
"loader": "file-loader",
45+
"options": {
46+
"name": "[name].[hash:20].[ext]",
47+
"limit": 10000
48+
}
49+
},
50+
{
51+
"test": /\.(jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,
52+
"loader": "url-loader",
53+
"options": {
54+
"name": "[name].[hash:20].[ext]",
55+
"limit": 10000
56+
}
57+
},
58+
{
59+
"test": /\.ts$/,
60+
"loader": "@ngtools/webpack"
61+
}
62+
]
63+
},
64+
"plugins": [
65+
new NoEmitOnErrorsPlugin(),
66+
new CopyWebpackPlugin([
67+
{
68+
"context": "src",
69+
"to": "",
70+
"from": {
71+
"glob": "assets\\**\\*",
72+
"dot": true
73+
}
74+
},
75+
{
76+
"context": "src",
77+
"to": "",
78+
"from": {
79+
"glob": "favicon.ico",
80+
"dot": true
81+
}
82+
}
83+
], {
84+
"ignore": [
85+
".gitkeep",
86+
"**/.DS_Store",
87+
"**/Thumbs.db"
88+
],
89+
"debug": "warning"
90+
}),
91+
new ProgressPlugin(),
92+
new CircularDependencyPlugin({
93+
"exclude": /(\\|\/)node_modules(\\|\/)/,
94+
"failOnError": false,
95+
"onDetected": false,
96+
"cwd": projectRoot
97+
}),
98+
new BaseHrefWebpackPlugin({}),
99+
new CommonsChunkPlugin({
100+
"name": [
101+
"inline"
102+
],
103+
"minChunks": null
104+
}),
105+
new CommonsChunkPlugin({
106+
"name": [
107+
"main"
108+
],
109+
"minChunks": 2,
110+
"async": "common"
111+
})
112+
],
113+
"node": {
114+
"fs": "empty",
115+
"global": true,
116+
"crypto": "empty",
117+
"tls": "empty",
118+
"net": "empty",
119+
"process": true,
120+
"module": false,
121+
"clearImmediate": false,
122+
"setImmediate": false
123+
},
124+
"devServer": {
125+
"historyApiFallback": true
126+
}
127+
};

0 commit comments

Comments
 (0)