mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 07:10:11 +00:00
Fix watch-admin command
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
e99fb210bc
commit
75066a4071
@ -55,7 +55,7 @@ export default {
|
|||||||
const { locales } = app;
|
const { locales } = app;
|
||||||
|
|
||||||
const importedTrads = await Promise.all(
|
const importedTrads = await Promise.all(
|
||||||
locales.map((locale) => {
|
locales.map(locale => {
|
||||||
return import(`./translations/${locale}.json`)
|
return import(`./translations/${locale}.json`)
|
||||||
.then(({ default: data }) => {
|
.then(({ default: data }) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const HomePage: React.VoidFunctionComponent = () => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>{pluginId}'s HomePage</h1>
|
<h1>{pluginId}'s HomePage</h1>
|
||||||
<p>Happy codineg</p>
|
<p>Happy coding</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,6 +16,5 @@
|
|||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": ["src/plugins/**/*.json", "./"],
|
"include": ["src/plugins/**/*.json", "./"],
|
||||||
|
|
||||||
"exclude": ["node_modules/", "dist/", "src/admin", ".cache/", ".tmp/"]
|
"exclude": ["node_modules/", "dist/", "src/admin", ".cache/", ".tmp/"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,16 +94,22 @@ async function clean({ appDir, buildDestDir }) {
|
|||||||
fs.removeSync(cacheDir);
|
fs.removeSync(cacheDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function watchAdmin({ appDir, plugins, dir, host, port, browser, options, useTypeScript }) {
|
async function watchAdmin({
|
||||||
console.log({ appDir });
|
appDir,
|
||||||
// TODO appDir
|
browser,
|
||||||
|
buildDestDir,
|
||||||
|
host,
|
||||||
|
options,
|
||||||
|
plugins,
|
||||||
|
port,
|
||||||
|
useTypeScript,
|
||||||
|
}) {
|
||||||
// Create the cache dir containing the front-end files.
|
// Create the cache dir containing the front-end files.
|
||||||
const cacheDir = path.join(dir, '.cache');
|
const cacheDir = path.join(appDir, '.cache');
|
||||||
await createCacheDir({ appDir, plugins, useTypeScript });
|
await createCacheDir({ appDir, plugins, useTypeScript });
|
||||||
|
|
||||||
const entry = path.join(cacheDir, 'admin', 'src');
|
const entry = path.join(cacheDir, 'admin', 'src');
|
||||||
const dest = path.join(dir, 'build');
|
const dest = path.join(buildDestDir, 'build');
|
||||||
const env = 'development';
|
const env = 'development';
|
||||||
|
|
||||||
// Roots for the @strapi/babel-plugin-switch-ee-ce
|
// Roots for the @strapi/babel-plugin-switch-ee-ce
|
||||||
@ -115,15 +121,15 @@ async function watchAdmin({ appDir, plugins, dir, host, port, browser, options,
|
|||||||
const pluginsPath = Object.keys(plugins).map(pluginName => plugins[pluginName].pathToPlugin);
|
const pluginsPath = Object.keys(plugins).map(pluginName => plugins[pluginName].pathToPlugin);
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
entry,
|
appDir,
|
||||||
cacheDir,
|
cacheDir,
|
||||||
pluginsPath,
|
|
||||||
dest,
|
dest,
|
||||||
|
entry,
|
||||||
env,
|
env,
|
||||||
port,
|
|
||||||
options,
|
options,
|
||||||
|
pluginsPath,
|
||||||
|
// port,
|
||||||
roots,
|
roots,
|
||||||
useTypeScript,
|
|
||||||
devServer: {
|
devServer: {
|
||||||
port,
|
port,
|
||||||
client: {
|
client: {
|
||||||
@ -143,9 +149,10 @@ async function watchAdmin({ appDir, plugins, dir, host, port, browser, options,
|
|||||||
disableDotRule: true,
|
disableDotRule: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
useTypeScript,
|
||||||
};
|
};
|
||||||
|
|
||||||
const webpackConfig = getCustomWebpackConfig(dir, args);
|
const webpackConfig = getCustomWebpackConfig(appDir, args);
|
||||||
|
|
||||||
const compiler = webpack(webpackConfig);
|
const compiler = webpack(webpackConfig);
|
||||||
|
|
||||||
@ -161,7 +168,7 @@ async function watchAdmin({ appDir, plugins, dir, host, port, browser, options,
|
|||||||
|
|
||||||
runServer();
|
runServer();
|
||||||
|
|
||||||
watchAdminFiles(dir, useTypeScript);
|
watchAdminFiles(appDir, useTypeScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -8,8 +8,8 @@ const DEFAULT_PLUGINS = [
|
|||||||
'content-manager',
|
'content-manager',
|
||||||
'upload',
|
'upload',
|
||||||
'email',
|
'email',
|
||||||
// 'i18n',
|
'i18n',
|
||||||
// 'users-permissions',
|
'users-permissions',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -151,6 +151,9 @@ function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles, polling }) {
|
|||||||
/tmp/,
|
/tmp/,
|
||||||
'**/src/admin/**',
|
'**/src/admin/**',
|
||||||
'**/src/plugins/**/admin/**',
|
'**/src/plugins/**/admin/**',
|
||||||
|
// FIXME pass the plugin path to the strapiAdmin.build and strapiAdmin.watch in order to stop copying
|
||||||
|
// the FE files when using TS
|
||||||
|
'**/dist/src/plugins/test/admin/**',
|
||||||
'**/documentation',
|
'**/documentation',
|
||||||
'**/documentation/**',
|
'**/documentation/**',
|
||||||
'**/node_modules',
|
'**/node_modules',
|
||||||
|
|||||||
@ -1,18 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
const strapiAdmin = require('@strapi/admin');
|
const strapiAdmin = require('@strapi/admin');
|
||||||
const { getConfigUrls, getAbsoluteServerUrl } = require('@strapi/utils');
|
const { getConfigUrls, getAbsoluteServerUrl } = require('@strapi/utils');
|
||||||
|
|
||||||
const ee = require('../utils/ee');
|
|
||||||
const addSlash = require('../utils/addSlash');
|
|
||||||
const strapi = require('../index');
|
|
||||||
const getEnabledPlugins = require('../core/loaders/plugins/get-enabled-plugins');
|
const getEnabledPlugins = require('../core/loaders/plugins/get-enabled-plugins');
|
||||||
|
const addSlash = require('../utils/addSlash');
|
||||||
|
const tsUtils = require('../utils/typescript');
|
||||||
|
const strapi = require('../index');
|
||||||
|
|
||||||
module.exports = async function({ browser }) {
|
module.exports = async function({ browser }) {
|
||||||
const dir = process.cwd();
|
const currentDirectory = process.cwd();
|
||||||
|
|
||||||
|
const isTSProject = await tsUtils.isTypeScriptProject(currentDirectory);
|
||||||
|
const buildDestDir = isTSProject ? path.join(currentDirectory, 'dist') : currentDirectory;
|
||||||
|
|
||||||
const strapiInstance = strapi({
|
const strapiInstance = strapi({
|
||||||
dir,
|
dir: buildDestDir,
|
||||||
autoReload: true,
|
autoReload: true,
|
||||||
serveAdminPanel: false,
|
serveAdminPanel: false,
|
||||||
});
|
});
|
||||||
@ -23,17 +26,12 @@ module.exports = async function({ browser }) {
|
|||||||
|
|
||||||
const adminPort = strapiInstance.config.get('admin.port', 8000);
|
const adminPort = strapiInstance.config.get('admin.port', 8000);
|
||||||
const adminHost = strapiInstance.config.get('admin.host', 'localhost');
|
const adminHost = strapiInstance.config.get('admin.host', 'localhost');
|
||||||
const adminWatchIgnoreFiles = strapiInstance.config.get('admin.watchIgnoreFiles', []);
|
|
||||||
|
|
||||||
const backendURL = getAbsoluteServerUrl(strapiInstance.config, true);
|
const backendURL = getAbsoluteServerUrl(strapiInstance.config, true);
|
||||||
|
|
||||||
ee({ dir });
|
|
||||||
|
|
||||||
// @convly we need to update this with the real check
|
|
||||||
const useTypeScript = false;
|
|
||||||
|
|
||||||
strapiAdmin.watchAdmin({
|
strapiAdmin.watchAdmin({
|
||||||
dir,
|
appDir: currentDirectory,
|
||||||
|
buildDestDir,
|
||||||
plugins,
|
plugins,
|
||||||
port: adminPort,
|
port: adminPort,
|
||||||
host: adminHost,
|
host: adminHost,
|
||||||
@ -41,9 +39,7 @@ module.exports = async function({ browser }) {
|
|||||||
options: {
|
options: {
|
||||||
backend: backendURL,
|
backend: backendURL,
|
||||||
adminPath: addSlash(adminPath),
|
adminPath: addSlash(adminPath),
|
||||||
watchIgnoreFiles: adminWatchIgnoreFiles,
|
|
||||||
features: ee.isEE ? ee.features.getEnabled() : [],
|
|
||||||
},
|
},
|
||||||
useTypeScript,
|
useTypeScript: isTSProject,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user