WebStorm & PHPStorm
Search for global node_modules folder (GLOBAL_NODE_MODULES)
node_modules folder (GLOBAL_NODE_MODULES)Use the
npm config get prefixcommand to find the path to themhyexecutable file.The global
node_modulesfolder should be around there somewhere. It varies between different systems, maybe it is right next to it, maybe inside alibdirectory next to it or the upper levels.Inside the global
node_modulesfolder, you'll findmhy/node_modules. The path to that directory is what we will need.
Generating config files
# Generating all possible config files mhy can provide
mhy config
# Use -o to overwrite existing files
mhy config -o
# Generate specific config files
mhy config prettier typescript webpack -ionode_modules resolution
node_modules resolutionSince you're using modules coming from mhy, you need to tell the IDE to include a node_modules folder outside your project's directory.
Find
GLOBAL_NODE_MODULES/mhy/node_modulesAdd the path at
File > Settings > Directoriesand mark it asExcludedandResource root.
Alias resolution
Alias resolution is done by Webpack. You only need to have a webpack.config.js file in your root.
ONLY in case you haven't run
mhy configyet to set-up your empty project, runmhy config webpack -ito initialize a config file.Make sure at
File > Settings > Webpackthat the feature is turned on.
Prettier (for automatic formatting on save; recommended)
While it's possible to add watchers without the Prettier plugin, the plugin simply helps you with pre-filling the necessary fields with the necessary values for your watcher.
Install
Prettier pluginfromFile > Settings > PluginsRestart IDE
Go to
File > Settings > Tools > File WatchersCreate watcher by clicking the
+sign.Select
prettierSet
ScopetoCurrent filewhich is more optimal.Set
ProgramtoGLOBAL_NODE_MODULES/mhy/node_modules/.bin/prettier(add.cmdon Windows).Save with
OK.(Optional) You might want to add change the
Levelof the watcher toGlobalto be able to re-use it across projects.
Unfortunately you'll need to create watcher for each
File Typeyou want the IDE to watch. By default it was creating it only for JavaScript. Most probably you want to addjsx, ts, tsxwatcher also. Do this with copying the watcher and change theFile Type.
TypeScript
Step 0: If it's necessary, please do
npm ifirst for your project, only createtsconfig.jsonfile after that. This is important to avoid duplicated@typesto be loaded.
ONLY in case you don't have
tsconfig.jsonfile yet:mhy config typescript -iGo to
File > Settings > Language & Frameworks > TypeScriptFor
TypeScriptsetGLOBAL_NODE_MODULES/mhy/node_modules/typescript
Note that in
mhyTypeScript is only being used to perform type-checks and to generate.d.tsfiles. You don't need to enable compilation, that is being done by SWC.
ESLint
ONLY in case you don't have
.eslintrcfile yet:mhy config eslint -iGo to
File > Settings > Language & Frameworks > JavaScript > Code Quality Tools > ESLintEnableFor
ESLint packagesetGLOBAL_NODE_MODULES/mhy/node_modules/eslintGo to
Help > Find Actionand typeregistryClick the first result (
Registry...)Scroll down to
eslint.additional.file.extensionsand setjs,jsx,ts,tsxas value.
Tips
Disable automatic
package.jsondependency inspection.Disable statement termination inspection.
CTRL+Enterat the end of any line. (ONLY in case you choose to continue using ASI which is the default setting.)Set 4 spaces for indent. (ONLY in case you choose to continue using the default setting.)
Make sure you use LF for line endings. Set it globally or project level, and also you can convert every file if needed by selecting the
root folderthenFile > Line separators.You might want most settings/watchers to be global (where possible), so you can re-use them for all your projects.
Last updated
Was this helpful?