Skip to content

Commit 57d6543

Browse files
authored
Merge pull request #18 from erkobridee/update/nx
Migrate to the nx 12.8.0
2 parents 4059cf0 + 232704b commit 57d6543

File tree

9 files changed

+2579
-3961
lines changed

9 files changed

+2579
-3961
lines changed

.storybook/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
const { appRootPath } = require('@nrwl/tao/src/utils/app-root');
2+
const configStorybook = require(`${appRootPath}/tools/config/webpack/storybook`);
3+
14
module.exports = {
25
stories: [],
36
addons: ['@storybook/addon-a11y', '@storybook/addon-essentials'],
7+
webpackFinal: async (config) => configStorybook(config),
48
};

.storybook/webpack.config.js

-17
This file was deleted.

apps/nextjs/next-env.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/// <reference types="next" />
22
/// <reference types="next/types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.
+77-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,81 @@
11
const rootMain = require('../../../../.storybook/main');
2+
const {
3+
addons: rootAddons,
4+
stories: rootStories,
5+
webpackFinal: rootWebpackFinal,
6+
} = rootMain;
27

3-
// Use the following syntax to add addons!
4-
//rootMain.addons.push('');
8+
module.exports = {
9+
...rootMain,
510

6-
rootMain.stories.push(
7-
...['../src/lib/**/*.stories.mdx', '../src/lib/**/*.stories.@(js|jsx|ts|tsx)']
8-
);
11+
addons: [...rootAddons],
912

10-
module.exports = rootMain;
13+
stories: [
14+
...rootStories,
15+
'../src/lib/**/*.stories.mdx',
16+
'../src/lib/**/*.stories.@(js|jsx|ts|tsx)',
17+
],
18+
19+
webpackFinal: async (config) => {
20+
config = await rootWebpackFinal(config);
21+
22+
// Found this here: https://github.com/nrwl/nx/issues/2859
23+
// And copied the part of the solution that made it work
24+
25+
const svgRuleIndex = config.module.rules.findIndex((rule) => {
26+
const { test } = rule;
27+
28+
return test.toString().startsWith('/\\.(svg|ico');
29+
});
30+
31+
config.module.rules[svgRuleIndex].test =
32+
/\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/;
33+
34+
config.module.rules.push(
35+
{
36+
test: /\.(png|jpe?g|gif|webp)$/,
37+
loader: require.resolve('url-loader'),
38+
options: {
39+
limit: 10000, // 10kB
40+
name: '[name].[hash:7].[ext]',
41+
},
42+
},
43+
{
44+
test: /\.svg$/,
45+
oneOf: [
46+
// If coming from JS/TS file, then transform into React component using SVGR.
47+
{
48+
issuer: {
49+
test: /\.[jt]sx?$/,
50+
},
51+
use: [
52+
'@svgr/webpack?-svgo,+titleProp,+ref![path]',
53+
{
54+
loader: require.resolve('url-loader'),
55+
options: {
56+
limit: 10000, // 10kB
57+
name: '[name].[hash:7].[ext]',
58+
esModule: false,
59+
},
60+
},
61+
],
62+
},
63+
// Fallback to plain URL loader.
64+
{
65+
use: [
66+
{
67+
loader: require.resolve('url-loader'),
68+
options: {
69+
limit: 10000, // 10kB
70+
name: '[name].[hash:7].[ext]',
71+
},
72+
},
73+
],
74+
},
75+
],
76+
}
77+
);
78+
79+
return config;
80+
},
81+
};

libs/shared/components/.storybook/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"include": ["../src/**/*", "./*.js"],
1414
"files": [
1515
"../../../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
16-
"../../../../node_modules/@nrwl/react/typings/image.d.ts"
16+
"../../../../node_modules/@nrwl/react/typings/image.d.ts",
17+
"../../../../node_modules/@nrwl/react/typings/styled-jsx.d.ts"
1718
]
1819
}

libs/shared/components/.storybook/webpack.config.js

-69
This file was deleted.

migrations.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"migrations": [
3+
{
4+
"cli": "nx",
5+
"version": "12.8.0-beta.0",
6+
"description": "Remove Typescript Preprocessor Plugin",
7+
"factory": "./src/migrations/update-12-8-0/remove-typescript-plugin",
8+
"package": "@nrwl/cypress",
9+
"name": "remove-typescript-plugin"
10+
},
11+
{
12+
"cli": "nx",
13+
"version": "12.8.0-beta.11",
14+
"description": "Adjust the Next.js lib babel configuration for styled-jsx",
15+
"factory": "./src/migrations/update-12-8-0/remove-styled-jsx-babel-plugin",
16+
"package": "@nrwl/next",
17+
"name": "fix-nextjs-lib-babel-config-12.8.0"
18+
},
19+
{
20+
"version": "12.8.0-beta.11",
21+
"cli": "nx",
22+
"description": "Adjust Storybook tsconfig to add styled-jsx typings",
23+
"factory": "./src/migrations/update-12-8-0/update-storybook-styled-jsx-typings",
24+
"package": "@nrwl/storybook",
25+
"name": "update-12-8.0"
26+
}
27+
]
28+
}

0 commit comments

Comments
 (0)