@codedesignai/nextjs-live-edit-plugin 1.0.0 → 1.0.1
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/index.js +32 -28
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const path = require('path');
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Next.js config wrapper that enables the live edit plugin.
|
|
5
|
+
* Uses Turbopack's built-in webpack loader support via turbopack.rules.
|
|
5
6
|
*
|
|
6
7
|
* Usage in next.config.js (CommonJS):
|
|
7
8
|
*
|
|
@@ -25,37 +26,40 @@ const path = require('path');
|
|
|
25
26
|
function withLiveEdit(nextConfig = {}, pluginOptions = {}) {
|
|
26
27
|
const sourceDirs = pluginOptions.sourceDirs || ['app', 'components', 'src'];
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Only add source mapping in development mode
|
|
30
|
+
if (process.env.NODE_ENV === 'production') {
|
|
31
|
+
return nextConfig;
|
|
32
|
+
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
use: [
|
|
42
|
-
{
|
|
43
|
-
loader: path.resolve(__dirname, 'source-mapper-loader.js'),
|
|
44
|
-
options: {
|
|
45
|
-
sourceDirs,
|
|
46
|
-
projectRoot: process.cwd(),
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
}
|
|
34
|
+
const loaderPath = path.resolve(__dirname, 'source-mapper-loader.js');
|
|
35
|
+
const loaderConfig = {
|
|
36
|
+
loader: loaderPath,
|
|
37
|
+
options: {
|
|
38
|
+
sourceDirs,
|
|
39
|
+
projectRoot: process.cwd(),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
43
|
+
// Merge with existing turbopack config
|
|
44
|
+
const existingTurbopack = nextConfig.turbopack || {};
|
|
45
|
+
const existingRules = existingTurbopack.rules || {};
|
|
57
46
|
|
|
58
|
-
|
|
47
|
+
return {
|
|
48
|
+
...nextConfig,
|
|
49
|
+
turbopack: {
|
|
50
|
+
...existingTurbopack,
|
|
51
|
+
rules: {
|
|
52
|
+
...existingRules,
|
|
53
|
+
// Apply our source mapper loader to JSX and TSX files
|
|
54
|
+
'*.jsx': {
|
|
55
|
+
loaders: [loaderConfig],
|
|
56
|
+
as: '*.jsx',
|
|
57
|
+
},
|
|
58
|
+
'*.tsx': {
|
|
59
|
+
loaders: [loaderConfig],
|
|
60
|
+
as: '*.tsx',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
59
63
|
},
|
|
60
64
|
};
|
|
61
65
|
}
|