lincd-cli 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/defaults/{app3/.env-cmdrc → app-with-backend/.env-cmdrc.json} +1 -1
- package/defaults/app-with-backend/babel.config.js +10 -0
- package/defaults/app-with-backend/backend/server.js +5 -0
- package/defaults/{app3 → app-with-backend}/frontend/scripts/build.js +15 -15
- package/defaults/app-with-backend/frontend/src/App.scss +45 -0
- package/defaults/app-with-backend/frontend/src/App.scss.json +1 -0
- package/defaults/app-with-backend/frontend/src/App.tsx +123 -0
- package/defaults/{app3 → app-with-backend}/frontend/src/components/Spinner.scss +1 -2
- package/defaults/app-with-backend/frontend/src/components/Spinner.scss.json +1 -0
- package/defaults/{app3 → app-with-backend}/frontend/src/components/Spinner.tsx +1 -1
- package/defaults/{app3 → app-with-backend}/frontend/src/index.tsx +0 -4
- package/defaults/app-with-backend/frontend/src/pages/Home.tsx +14 -0
- package/defaults/app-with-backend/frontend/src/pages/Page1.tsx +7 -0
- package/defaults/{app2 → app-with-backend}/frontend/web/favicon.ico +0 -0
- package/defaults/{app3 → app-with-backend}/package.json +12 -11
- package/defaults/{app3 → app-with-backend}/tsconfig.json +0 -0
- package/lib/cli.js +3 -3
- package/lib/config-grunt.js +1 -4
- package/lib/config-webpack.js +74 -40
- package/lib/plugins/declaration-plugin.js +75 -69
- package/lib/plugins/externalise-modules.js +30 -14
- package/package.json +23 -18
- package/defaults/app2/backend/src/server.js +0 -152
- package/defaults/app2/backend/src/server.js.map +0 -1
- package/defaults/app2/backend/src/server.tsx +0 -137
- package/defaults/app2/frontend/scripts/build.js +0 -100
- package/defaults/app2/frontend/src/App.js +0 -52
- package/defaults/app2/frontend/src/App.js.map +0 -1
- package/defaults/app2/frontend/src/App.tsx +0 -35
- package/defaults/app2/frontend/src/Html.js +0 -12
- package/defaults/app2/frontend/src/Html.js.map +0 -0
- package/defaults/app2/frontend/src/Html.tsx +0 -29
- package/defaults/app2/frontend/src/Layout.js +0 -153
- package/defaults/app2/frontend/src/Layout.js.map +0 -1
- package/defaults/app2/frontend/src/Layout.tsx +0 -5
- package/defaults/app2/frontend/src/Spinner.js +0 -9
- package/defaults/app2/frontend/src/Spinner.js.map +0 -0
- package/defaults/app2/frontend/src/Spinner.scss +0 -17
- package/defaults/app2/frontend/src/Spinner.tsx +0 -10
- package/defaults/app2/frontend/src/index.js +0 -14
- package/defaults/app2/frontend/src/index.js.map +0 -0
- package/defaults/app2/frontend/src/index.tsx +0 -16
- package/defaults/app2/package.json +0 -71
- package/defaults/app2/tailwind.config.js +0 -3
- package/defaults/app2/tsconfig.json +0 -17
- package/defaults/app3/backend/server.js +0 -5
- package/defaults/app3/frontend/scripts/webpack-config.js +0 -121
- package/defaults/app3/frontend/src/App.tsx +0 -72
- package/defaults/app3/frontend/src/Header.tsx +0 -16
- package/defaults/app3/frontend/src/Html.tsx +0 -29
- package/defaults/app3/frontend/src/Layout.tsx +0 -11
- package/defaults/app3/frontend/src/_tailwind.scss +0 -3
- package/defaults/app3/frontend/src/pages/Home.tsx +0 -15
- package/defaults/app3/frontend/src/pages/Page1.scss +0 -3
- package/defaults/app3/frontend/src/pages/Page1.scss.json +0 -1
- package/defaults/app3/frontend/src/pages/Page1.tsx +0 -15
- package/defaults/app3/frontend/src/pages/Page2.scss +0 -16
- package/defaults/app3/frontend/src/pages/Page2.scss.json +0 -1
- package/defaults/app3/frontend/src/pages/Page2.tsx +0 -21
- package/defaults/app3/frontend/web/favicon.ico +0 -0
- package/defaults/app3/tailwind.config.js +0 -3
- package/plugins/declaration-plugin.js +0 -248
- package/plugins/externalise-modules.js +0 -161
- package/plugins/watch-run.js +0 -47
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
require('@babel/register')({ extensions: ['.ts', '.tsx'] });
|
|
3
|
+
const LincdServer = require("lincd-server/lib/shapes/LincdServer");
|
|
4
|
+
let server = new LincdServer.LincdServer({ loadAppComponent: () => require("../frontend/src/App").default });
|
|
5
|
+
server.start();
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
const
|
|
2
|
+
const webpack = require("webpack");
|
|
3
|
+
const config = require("lincd-server/site.webpack.config");
|
|
4
4
|
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
const isProduction = process.env.NODE_ENV === 'production';
|
|
7
|
-
|
|
8
|
-
let webpackConfig = require("./webpack-config");
|
|
9
|
-
|
|
10
|
-
// Can be overwritten by environment variables
|
|
11
|
-
// Should relate to express.static in server.ts, which makes the build files available through a URL
|
|
12
|
-
const ASSET_PATH = process.env.ASSET_PATH || '/js/';
|
|
13
|
-
|
|
14
|
-
webpack(webpackConfig(),(err, stats) => {
|
|
5
|
+
webpack(config, (err, stats) => { // [Stats Object](#stats-object)
|
|
15
6
|
if (err) {
|
|
16
7
|
console.error(err.stack || err);
|
|
17
8
|
if (err.details) {
|
|
@@ -25,10 +16,19 @@ webpack(webpackConfig(),(err, stats) => {
|
|
|
25
16
|
console.log('Finished running webpack with errors.');
|
|
26
17
|
info.errors.forEach((e) => console.error(e));
|
|
27
18
|
} else {
|
|
28
|
-
console.log(chalk.green('Finished running webpack.'));
|
|
19
|
+
// console.log(chalk.green('Finished running webpack.'));
|
|
20
|
+
console.log(stats.toString({
|
|
21
|
+
chunks:false,
|
|
22
|
+
assets:true,
|
|
23
|
+
entryPoints:false,
|
|
24
|
+
modules:false,
|
|
25
|
+
moduleAssets:false,
|
|
26
|
+
moduleChunks:false,
|
|
27
|
+
colors: true,
|
|
28
|
+
}));
|
|
29
29
|
// console.log(
|
|
30
30
|
// chalk.green('\t'+Object.keys(stats.compilation.assets).join('\n\t')),
|
|
31
31
|
// );
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
process.exit();
|
|
34
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.error {
|
|
2
|
+
color: white;
|
|
3
|
+
margin: 2rem;
|
|
4
|
+
|
|
5
|
+
pre {
|
|
6
|
+
white-space: pre-wrap;
|
|
7
|
+
padding: 1rem;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.content {
|
|
12
|
+
display: block;
|
|
13
|
+
background-color: #f3f3f3;
|
|
14
|
+
box-shadow: 2px 2px 2px rgba(68, 68, 68, 0.3);
|
|
15
|
+
padding: 1rem;
|
|
16
|
+
margin: 1rem 0;
|
|
17
|
+
|
|
18
|
+
code {
|
|
19
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
|
|
20
|
+
margin: 0.5rem 0;
|
|
21
|
+
|
|
22
|
+
pre {
|
|
23
|
+
padding: 1rem;
|
|
24
|
+
background-color: #bfe7fc;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.main {
|
|
30
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans',
|
|
31
|
+
'Droid Sans', 'Helvetica Neue', sans-serif;
|
|
32
|
+
width: 66.6%;
|
|
33
|
+
margin: auto;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.header {
|
|
37
|
+
display: block;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.menu {
|
|
41
|
+
margin: 1rem 0;
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-template-columns: repeat(6, 1fr);
|
|
44
|
+
grid-gap: 1rem;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"error":"${name}_App_error","content":"${name}_App_content","main":"${name}_App_main","header":"${name}_App_header","menu":"${name}_App_menu"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {Link} from 'react-router-dom';
|
|
2
|
+
import {lazy, Suspense} from 'react';
|
|
3
|
+
import {ErrorBoundary} from 'react-error-boundary';
|
|
4
|
+
import Spinner from './components/Spinner';
|
|
5
|
+
import {Route, Routes} from 'react-router-dom';
|
|
6
|
+
import {Storage} from 'lincd/lib/utils/Storage';
|
|
7
|
+
import {FrontendFileStore} from 'lincd-server/lib/shapes/FrontendFileStore';
|
|
8
|
+
|
|
9
|
+
//Note that by default LINCD apps are set up with support for SCSS (sass) and CSS Modules
|
|
10
|
+
//So any .scss file needs to be imported by itself
|
|
11
|
+
import "./App.scss";
|
|
12
|
+
//and then the .scss.json file needs to be imported to access the class names (this file will be automatically generated)
|
|
13
|
+
import style from "./App.scss.json";
|
|
14
|
+
|
|
15
|
+
//In React 18 you can use 'lazy' to import pages only when you need them.
|
|
16
|
+
//This will cause webpack to create multiple bundles, and the right one is automatically loaded
|
|
17
|
+
const Home = lazy(() => import('./pages/Home' /* webpackPrefetch: true */));
|
|
18
|
+
const Page1 = lazy(() => import('./pages/Page1' /* webpackPrefetch: true */));
|
|
19
|
+
|
|
20
|
+
//store all quads in a file on the backend named 'main'
|
|
21
|
+
let store = new FrontendFileStore('main');
|
|
22
|
+
Storage.setDefaultStore(store);
|
|
23
|
+
|
|
24
|
+
declare var window;
|
|
25
|
+
export default function App({assets = typeof window !== 'undefined' ? window['assetManifest'] : {}}) {
|
|
26
|
+
return (
|
|
27
|
+
<Html assets={assets} title="${name} - LINCD App">
|
|
28
|
+
<Suspense fallback={<Spinner />}>
|
|
29
|
+
<ErrorBoundary FallbackComponent={Error}>
|
|
30
|
+
<Content />
|
|
31
|
+
</ErrorBoundary>
|
|
32
|
+
</Suspense>
|
|
33
|
+
</Html>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Content() {
|
|
38
|
+
return (
|
|
39
|
+
<Layout>
|
|
40
|
+
<div className={style.content}>
|
|
41
|
+
<Routes>
|
|
42
|
+
<Route
|
|
43
|
+
path="/"
|
|
44
|
+
element={
|
|
45
|
+
<Suspense fallback={<Spinner />}>
|
|
46
|
+
<Home />
|
|
47
|
+
</Suspense>
|
|
48
|
+
}
|
|
49
|
+
/>
|
|
50
|
+
<Route
|
|
51
|
+
path="/page1"
|
|
52
|
+
element={
|
|
53
|
+
<Suspense fallback={<Spinner />}>
|
|
54
|
+
<Page1 />
|
|
55
|
+
</Suspense>
|
|
56
|
+
}
|
|
57
|
+
/>
|
|
58
|
+
</Routes>
|
|
59
|
+
</div>
|
|
60
|
+
</Layout>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function Error({error}) {
|
|
65
|
+
return (
|
|
66
|
+
<div className={style.error}>
|
|
67
|
+
<h1>Application Error</h1>
|
|
68
|
+
<pre>{error.stack}</pre>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function Layout({children}) {
|
|
74
|
+
return (
|
|
75
|
+
<main className={style.main}>
|
|
76
|
+
<Header />
|
|
77
|
+
{children}
|
|
78
|
+
</main>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function Header()
|
|
83
|
+
{
|
|
84
|
+
return (
|
|
85
|
+
<header className={style.header}>
|
|
86
|
+
<h1>${name}</h1>
|
|
87
|
+
<nav className={style.menu}>
|
|
88
|
+
<Link to="/">Home</Link>
|
|
89
|
+
<Link to="/page1">Page 1</Link>
|
|
90
|
+
</nav>
|
|
91
|
+
</header>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function Html({assets, children, title}) {
|
|
96
|
+
return (
|
|
97
|
+
<html lang="en">
|
|
98
|
+
<head>
|
|
99
|
+
<meta charSet="utf-8" />
|
|
100
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
101
|
+
<link rel="shortcut icon" href="/static/favicon.ico" />
|
|
102
|
+
<link rel="stylesheet" href={assets['main.css']} />
|
|
103
|
+
{assets['tailwind-cdn'] && (
|
|
104
|
+
<script src={assets['tailwind-cdn']}></script>
|
|
105
|
+
)}
|
|
106
|
+
<title>{title}</title>
|
|
107
|
+
</head>
|
|
108
|
+
<body>
|
|
109
|
+
<noscript
|
|
110
|
+
dangerouslySetInnerHTML={{
|
|
111
|
+
__html: `<b>Enable JavaScript to run this app.</b>`,
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
{children}
|
|
115
|
+
<script
|
|
116
|
+
dangerouslySetInnerHTML={{
|
|
117
|
+
__html: `assetManifest = ${JSON.stringify(assets)};`,
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
</body>
|
|
121
|
+
</html>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"spinner":"${name}_Spinner_spinner","active":"${name}_Spinner_active","spin":"${name}_Spinner_spin"}
|
|
@@ -2,7 +2,7 @@ import './Spinner.scss';
|
|
|
2
2
|
export default function Spinner({active = true}) {
|
|
3
3
|
return (
|
|
4
4
|
<div
|
|
5
|
-
className={['spinner', active && '
|
|
5
|
+
className={['spinner', active && 'active'].join(' ')}
|
|
6
6
|
role="progressbar"
|
|
7
7
|
aria-busy={active ? 'true' : 'false'}
|
|
8
8
|
/>
|
|
File without changes
|
|
@@ -12,15 +12,9 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"scripts": {
|
|
14
14
|
"start": "npm run server:dev",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"server:
|
|
18
|
-
"server:prod": "env-cmd -e prod nodemon -e js,json --delay 1 ./backend/server.js",
|
|
19
|
-
"tsc": "cross-env NODE_ENV=development tsc --watch --project ./tsconfig.json",
|
|
20
|
-
"tsc:prod": "cross-env NODE_ENV=production tsc --project ./tsconfig.json",
|
|
21
|
-
"bundler:dev": "cross-env NODE_ENV=development nodemon --watch frontend/scripts frontend/scripts/build.js",
|
|
22
|
-
"bundler:prod": "cross-env NODE_ENV=production node frontend/scripts/build.js",
|
|
23
|
-
"setup": "cross-env NODE_ENV=development tsc --project ./tsconfig.json"
|
|
15
|
+
"build": "env-cmd -e prod node frontend/scripts/build.js",
|
|
16
|
+
"server:dev": "env-cmd -e dev nodemon --watch ../../modules/lincd-server/lib --watch ../../modules/lincd-server/site.webpack.config.js ./backend/server.js",
|
|
17
|
+
"server:prod": "env-cmd -e prod nodemon -e js,json s ./backend/server.js"
|
|
24
18
|
},
|
|
25
19
|
"keywords": [
|
|
26
20
|
"lincd",
|
|
@@ -30,7 +24,15 @@
|
|
|
30
24
|
"web3"
|
|
31
25
|
],
|
|
32
26
|
"dependencies": {
|
|
27
|
+
"@babel/cli": "^7.18.10",
|
|
28
|
+
"@babel/core": "^7.19.1",
|
|
29
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
30
|
+
"@babel/preset-env": "^7.19.1",
|
|
31
|
+
"@babel/preset-react": "^7.18.6",
|
|
32
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
33
|
+
"@babel/register": "^7.18.9",
|
|
33
34
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
|
|
35
|
+
"babel-loader": "^8.2.5",
|
|
34
36
|
"fork-ts-checker-webpack-plugin": "6.2.6",
|
|
35
37
|
"is-object": "^1.0.2",
|
|
36
38
|
"lincd": "^0.3",
|
|
@@ -69,9 +71,8 @@
|
|
|
69
71
|
"resolve": "1.12.0",
|
|
70
72
|
"sass-loader": "^10.0",
|
|
71
73
|
"tailwindcss": "^3.0.24",
|
|
72
|
-
"ts-loader": "^8.0.12",
|
|
73
74
|
"typescript": "4.6.4",
|
|
74
|
-
"webpack": "
|
|
75
|
+
"webpack": "^5.74.0",
|
|
75
76
|
"webpack-cli": "^4.2.0"
|
|
76
77
|
}
|
|
77
78
|
}
|
|
File without changes
|
package/lib/cli.js
CHANGED
|
@@ -834,17 +834,17 @@ var createApp = function (name, basePath) {
|
|
|
834
834
|
if (!fs.existsSync(targetFolder)) {
|
|
835
835
|
fs.mkdirSync(targetFolder);
|
|
836
836
|
}
|
|
837
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', '
|
|
837
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'app-with-backend'), targetFolder);
|
|
838
838
|
// fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
|
|
839
839
|
log("Creating new LINCD application '" + name + "'");
|
|
840
840
|
//replace variables in some of the copied files
|
|
841
|
-
replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/
|
|
841
|
+
replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/App.scss.json', 'frontend/src/components/Spinner.scss.json');
|
|
842
842
|
return [4 /*yield*/, hasYarnInstalled()];
|
|
843
843
|
case 1:
|
|
844
844
|
hasYarn = _b.sent();
|
|
845
845
|
installCommand = hasYarn ? 'yarn install' : 'npm install';
|
|
846
846
|
runCommand = hasYarn ? 'yarn' : 'npm run';
|
|
847
|
-
return [4 /*yield*/, execp("cd ".concat(hyphenName, " && ").concat(installCommand
|
|
847
|
+
return [4 /*yield*/, execp("cd ".concat(hyphenName, " && ").concat(installCommand), true)["catch"](function (err) {
|
|
848
848
|
console.warn('Could not install dependencies or start application');
|
|
849
849
|
})];
|
|
850
850
|
case 2:
|
package/lib/config-grunt.js
CHANGED
|
@@ -168,10 +168,7 @@ function setupGrunt(grunt, moduleName, config) {
|
|
|
168
168
|
options: {
|
|
169
169
|
stats: {
|
|
170
170
|
chunks: false,
|
|
171
|
-
version: false
|
|
172
|
-
warningsFilter: function (warning) {
|
|
173
|
-
return warning.indexOf('There are multiple modules') !== -1;
|
|
174
|
-
}
|
|
171
|
+
version: false
|
|
175
172
|
}
|
|
176
173
|
},
|
|
177
174
|
dev: (0, config_webpack_1.generateWebpackConfig)('dev', moduleName, Object.assign({
|
package/lib/config-webpack.js
CHANGED
|
@@ -20,20 +20,22 @@ var externalise_modules_1 = __importDefault(require("./plugins/externalise-modul
|
|
|
20
20
|
var watch_run_1 = __importDefault(require("./plugins/watch-run"));
|
|
21
21
|
var utils_1 = require("./utils");
|
|
22
22
|
var colors = require("colors");
|
|
23
|
+
// console.log('Webpack '+require('webpack/package.json').version);
|
|
24
|
+
// console.log('ts-loader '+require('ts-loader/package.json').version);
|
|
23
25
|
var fs = require('fs');
|
|
24
26
|
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
25
27
|
var chalk = require('chalk');
|
|
26
28
|
var webpack = require('webpack');
|
|
27
29
|
var path = require('path');
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
30
|
+
// const WebpackLicencePlugin = require('webpack-license-plugin');
|
|
31
|
+
// const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
31
32
|
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
32
33
|
var TerserPlugin = require('terser-webpack-plugin');
|
|
33
34
|
var exec = require('child_process').exec;
|
|
34
35
|
var NODE_ENV = process.env.NODE_ENV;
|
|
35
36
|
var nodeProduction = NODE_ENV == 'production';
|
|
36
37
|
// const libraryName = 'lincd';
|
|
38
|
+
process.traceDeprecation = true;
|
|
37
39
|
function generateWebpackConfig(buildName, moduleName, config) {
|
|
38
40
|
if (config === void 0) { config = {}; }
|
|
39
41
|
if (!config.externals)
|
|
@@ -59,21 +61,22 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
59
61
|
}
|
|
60
62
|
var tsConfig = JSON.parse(fs.readFileSync(configFile));
|
|
61
63
|
var plugins = [
|
|
62
|
-
new webpack.DefinePlugin({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}),
|
|
66
|
-
new webpack.NoEmitOnErrorsPlugin(),
|
|
67
|
-
new ExtractTextPlugin(config.cssFileName ? config.cssFileName : cleanModuleName + '.css'),
|
|
64
|
+
// new webpack.DefinePlugin({
|
|
65
|
+
// 'process.env.BROWSER': JSON.stringify(true),
|
|
66
|
+
// 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
67
|
+
// }),
|
|
68
|
+
// new webpack.NoEmitOnErrorsPlugin(),
|
|
69
|
+
// new ExtractTextPlugin(config.cssFileName ? config.cssFileName : cleanModuleName + '.css'),
|
|
68
70
|
new MiniCssExtractPlugin({
|
|
69
71
|
// linkType: false,
|
|
70
72
|
filename: config.cssFileName ? config.cssFileName : cleanModuleName + '.css'
|
|
71
73
|
}),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
74
|
+
//currently not compatible with webpack 5
|
|
75
|
+
// new WebpackLicencePlugin({
|
|
76
|
+
// excludedPackageTest: (packageName, version) => {
|
|
77
|
+
// return packageName.indexOf('lincd') !== -1;
|
|
78
|
+
// },
|
|
79
|
+
// }),
|
|
77
80
|
];
|
|
78
81
|
if (config.debug) {
|
|
79
82
|
plugins.push(new watch_run_1["default"]());
|
|
@@ -114,12 +117,12 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
114
117
|
debug: 'debug' in config ? config.debug : false
|
|
115
118
|
}));
|
|
116
119
|
}
|
|
117
|
-
var resolvePlugins = [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
];
|
|
120
|
+
// var resolvePlugins = [
|
|
121
|
+
// new TsconfigPathsPlugin({
|
|
122
|
+
// configFile: configFile,
|
|
123
|
+
// silent: true,
|
|
124
|
+
// }),
|
|
125
|
+
// ];
|
|
123
126
|
var aliases = config.alias || {};
|
|
124
127
|
var rules = [
|
|
125
128
|
{
|
|
@@ -142,7 +145,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
142
145
|
'postcss-nested': {},
|
|
143
146
|
// "postcss-scss": {}, //<-- only add this back if the build gets stuck on //comments in scss files, but I dont think that will be the case anymore
|
|
144
147
|
'postcss-modules': {
|
|
145
|
-
//by default postcss-modules will put out a json file right next to the original css / scss file, this method defines what classnames to use
|
|
148
|
+
// //by default postcss-modules will put out a json file right next to the original css / scss file, this method defines what classnames to use
|
|
146
149
|
generateScopedName: utils_1.generateScopedName,
|
|
147
150
|
globalModulePaths: [/tailwind/]
|
|
148
151
|
},
|
|
@@ -177,6 +180,30 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
177
180
|
},
|
|
178
181
|
]
|
|
179
182
|
},
|
|
183
|
+
// {
|
|
184
|
+
// test: /\.(ts|tsx)$/,
|
|
185
|
+
// exclude: /node_modules/,
|
|
186
|
+
// //include: [path.join(process.cwd(),"frontend")], // only bundle files in this directory
|
|
187
|
+
// use: {
|
|
188
|
+
// loader: "babel-loader", // cf. .babelrc.json in this folder and browser list in package.json
|
|
189
|
+
// options: {
|
|
190
|
+
// // plugins: productionMode ? [] : ["react-refresh/babel"],
|
|
191
|
+
// cacheCompression: false,
|
|
192
|
+
// cacheDirectory: true,
|
|
193
|
+
// presets: [
|
|
194
|
+
// "@babel/preset-env",
|
|
195
|
+
// ["@babel/preset-react", {"runtime": "automatic"}],
|
|
196
|
+
// "@babel/preset-typescript",
|
|
197
|
+
// ],
|
|
198
|
+
// plugins: [
|
|
199
|
+
// "@babel/plugin-transform-runtime",
|
|
200
|
+
// ["@babel/plugin-proposal-decorators",{
|
|
201
|
+
// decoratorsBeforeExport:true
|
|
202
|
+
// }]
|
|
203
|
+
// ],
|
|
204
|
+
// },
|
|
205
|
+
// },
|
|
206
|
+
// },
|
|
180
207
|
{
|
|
181
208
|
test: /\.tsx?$/,
|
|
182
209
|
use: [
|
|
@@ -194,15 +221,15 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
194
221
|
},
|
|
195
222
|
]
|
|
196
223
|
},
|
|
197
|
-
{
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
},
|
|
224
|
+
// {
|
|
225
|
+
// enforce: 'pre',
|
|
226
|
+
// test: /\.js$/,
|
|
227
|
+
// use: [
|
|
228
|
+
// {
|
|
229
|
+
// loader: 'source-map-loader',
|
|
230
|
+
// },
|
|
231
|
+
// ],
|
|
232
|
+
// },
|
|
206
233
|
];
|
|
207
234
|
if (es5 && config.internalsources && config.internalsources.length > 0) {
|
|
208
235
|
//usually a module that transpiles to es5 will only have es5 code in the bundle.
|
|
@@ -211,7 +238,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
211
238
|
//so we fix that here by just referring directly to the typescript source instead of the transpiled js for internalised modules
|
|
212
239
|
//however this means that for internalised modules THE SOURCE CODE NEEDS TO BE AVAILABLE. This is currently NOT the case with how we publish modules to yarn
|
|
213
240
|
//so that means internalised modules need to be LOCALLY AVAILABLE with yarn workspaces
|
|
214
|
-
plugins.push(new webpack.NormalModuleReplacementPlugin(
|
|
241
|
+
plugins.push(new webpack.NormalModuleReplacementPlugin(/lincd\/lib\//, function (resource, match) {
|
|
215
242
|
var moduleName = resource.request.match(/lincd\/lib\//)[1];
|
|
216
243
|
if (config.internalsources.indexOf(moduleName) !== -1) {
|
|
217
244
|
console.log(colors.magenta('internal sources + ES5: Replacing /lib/ with /src/ for source-internalised module ' + moduleName));
|
|
@@ -228,17 +255,17 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
228
255
|
path: path.resolve(process.cwd(), config.bundlePath || 'dist'),
|
|
229
256
|
devtoolModuleFilenameTemplate: moduleName + '/[resource-path]'
|
|
230
257
|
},
|
|
231
|
-
devtool: productionMode ? '
|
|
258
|
+
devtool: productionMode ? 'source-map' : 'cheap-module-source-map',
|
|
259
|
+
// devtool: productionMode ? 'cheap-source-map' : 'cheap-source-map',
|
|
232
260
|
mode: productionMode ? 'production' : 'development',
|
|
233
261
|
//fixing a persistent but strange build error here that showed up once, this is a workaround. See: https://github.com/webpack-contrib/css-loader/issues/447
|
|
234
|
-
node: {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
},
|
|
262
|
+
// node: {
|
|
263
|
+
// fs: 'empty',
|
|
264
|
+
// child_process: 'empty',
|
|
265
|
+
// },
|
|
238
266
|
resolve: {
|
|
239
267
|
extensions: ['.webpack.js', '.js', '.ts', '.tsx', '.json'],
|
|
240
|
-
alias: aliases
|
|
241
|
-
plugins: resolvePlugins
|
|
268
|
+
alias: aliases
|
|
242
269
|
},
|
|
243
270
|
resolveLoader: {
|
|
244
271
|
modules: [
|
|
@@ -269,12 +296,19 @@ function generateWebpackConfig(buildName, moduleName, config) {
|
|
|
269
296
|
externals: (0, externalise_modules_1["default"])(config, es5),
|
|
270
297
|
plugins: plugins,
|
|
271
298
|
stats: {
|
|
272
|
-
errorDetails:
|
|
299
|
+
errorDetails: true,
|
|
273
300
|
chunks: false,
|
|
274
|
-
children:
|
|
301
|
+
children: true,
|
|
275
302
|
version: true,
|
|
276
303
|
hash: false,
|
|
304
|
+
entrypoints: false,
|
|
277
305
|
modules: false
|
|
306
|
+
},
|
|
307
|
+
//hide some info from output when in watch mode to keep it succinct
|
|
308
|
+
//stats:{chunks:!watch,version:!watch}//hide some info from output when in watch mode to keep it succinct
|
|
309
|
+
cache: {
|
|
310
|
+
// https://webpack.js.org/configuration/other-options/#cache
|
|
311
|
+
type: "filesystem"
|
|
278
312
|
}
|
|
279
313
|
};
|
|
280
314
|
}
|