mirror of
https://github.com/motion-canvas/motion-canvas.git
synced 2026-01-11 14:57:56 -05:00
feat: add support for npm workspaces
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,4 @@
|
||||
node_modules
|
||||
lib
|
||||
test
|
||||
.idea
|
||||
tsconfig.tsbuildinfo
|
||||
.idea
|
||||
@@ -8,6 +8,7 @@ import WebpackDevServer from 'webpack-dev-server';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import meow from 'meow';
|
||||
import UIPlugin from './plugins/UIPlugin.mjs';
|
||||
import {createRequire} from 'module';
|
||||
|
||||
const cli = meow({
|
||||
importMeta: import.meta,
|
||||
@@ -28,9 +29,16 @@ const cli = meow({
|
||||
},
|
||||
});
|
||||
|
||||
cli.flags.uiPath ||= cli.flags.uiServer
|
||||
? 'http://localhost:9001/main.js'
|
||||
: './node_modules/@motion-canvas/ui/dist';
|
||||
if (cli.flags.uiServer) {
|
||||
cli.flags.uiPath ||= 'http://localhost:9001/main.js';
|
||||
} else {
|
||||
if (cli.flags.uiPath) {
|
||||
cli.flags.uiPath = path.resolve(process.cwd(), cli.flags.uiPath);
|
||||
} else {
|
||||
const require = createRequire(import.meta.url);
|
||||
cli.flags.uiPath = path.dirname(require.resolve('@motion-canvas/ui'));
|
||||
}
|
||||
}
|
||||
|
||||
const projectFile = path.resolve(process.cwd(), cli.input[0]);
|
||||
const renderOutput = path.resolve(process.cwd(), cli.flags.output);
|
||||
@@ -87,16 +95,11 @@ const compiler = webpack({
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: [
|
||||
path.resolve(process.cwd(), './node_modules'),
|
||||
path.resolve(__dirname, '../node_modules'),
|
||||
'node_modules',
|
||||
path.resolve(__dirname, './loaders'),
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
modules: [
|
||||
path.resolve(process.cwd(), './node_modules'),
|
||||
path.resolve(__dirname, '../node_modules'),
|
||||
],
|
||||
extensions: ['.js', '.ts', '.tsx'],
|
||||
},
|
||||
output: {
|
||||
@@ -133,12 +136,11 @@ const server = new WebpackDevServer(
|
||||
});
|
||||
|
||||
if (!cli.flags.uiServer) {
|
||||
const ui = path.resolve(process.cwd(), cli.flags.uiPath);
|
||||
middlewares.unshift({
|
||||
name: 'ui',
|
||||
path: '/ui/:name',
|
||||
middleware: (req, res) => {
|
||||
fs.createReadStream(path.join(ui, req.params.name), {
|
||||
fs.createReadStream(path.join(cli.flags.uiPath, req.params.name), {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
.on('error', () => res.sendStatus(404))
|
||||
@@ -152,4 +154,4 @@ const server = new WebpackDevServer(
|
||||
},
|
||||
compiler,
|
||||
);
|
||||
server.start().catch(console.error);
|
||||
server.start().catch(console.error);
|
||||
@@ -1,10 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"baseUrl": "src",
|
||||
"outDir": "lib",
|
||||
"composite": true,
|
||||
"sourceMap": true,
|
||||
"inlineSourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"module": "esnext",
|
||||
"target": "es2020",
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"module": "esnext",
|
||||
"target": "es2020",
|
||||
"allowJs": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "@motion-canvas/core/lib",
|
||||
"paths": {
|
||||
"*": [
|
||||
"../node_modules/*",
|
||||
"../node_modules/@motion-canvas/core/node_modules/*",
|
||||
"../node_modules/@motion-canvas/core/node_modules/@types/*"
|
||||
]
|
||||
},
|
||||
"typeRoots": [
|
||||
"../node_modules/@motion-canvas/core/node_modules/@types",
|
||||
"../node_modules/@types"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user