\href{https://www.npmjs.com/package/pnp-webpack-plugin}{\texttt{ }} \href{https://www.npmjs.com/package/pnp-webpack-plugin}{\texttt{ }}

{\itshape This plugin is also available for Jest (\href{https://github.com/arcanis/jest-pnp-resolver}{\texttt{ jest-\/pnp-\/resolver}}), Rollup (\href{https://github.com/arcanis/rollup-plugin-pnp-resolve}{\texttt{ rollup-\/plugin-\/pnp-\/resolve}}), and Type\+Script (\href{https://github.com/arcanis/ts-pnp}{\texttt{ ts-\/pnp}})}\hypertarget{md_sfcode_node_modules_pnp_webpack_plugin_README_autotoc_md20431}{}\doxysection{Installation}\label{md_sfcode_node_modules_pnp_webpack_plugin_README_autotoc_md20431}

\begin{DoxyCode}{0}
\DoxyCodeLine{yarn add -\/D pnp-\/webpack-\/plugin }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pnp_webpack_plugin_README_autotoc_md20432}{}\doxysection{Usage}\label{md_sfcode_node_modules_pnp_webpack_plugin_README_autotoc_md20432}
Simply add the plugin to both the {\ttfamily resolver} and {\ttfamily resolve\+Loader}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const PnpWebpackPlugin = require(`pnp-\/webpack-\/plugin`);}
\DoxyCodeLine{}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  resolve: \{}
\DoxyCodeLine{    plugins: [}
\DoxyCodeLine{      PnpWebpackPlugin,}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  resolveLoader: \{}
\DoxyCodeLine{    plugins: [}
\DoxyCodeLine{      PnpWebpackPlugin.moduleLoader(module),}
\DoxyCodeLine{    ],}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}


The {\ttfamily resolve} entry will take care of correctly resolving the dependencies required by your program, and the {\ttfamily resolve\+Loader} entry will help Webpack find the location of the loaders on the disk. Note that in this case, all loaders will be resolved relative to the package containing your configuration.

In case part of your configuration comes from third-\/party packages that use their own loaders, make sure they use {\ttfamily require.\+resolve} -\/ this will ensure that the resolution process is portable accross environments (including when Plug\textquotesingle{}n\textquotesingle{}Play isn\textquotesingle{}t enabled), and prevent it from relying on undefined behaviors\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  module: \{}
\DoxyCodeLine{    rules: [\{}
\DoxyCodeLine{      test: /\(\backslash\).js\$/,}
\DoxyCodeLine{      loader: require.resolve('babel-\/loader'),}
\DoxyCodeLine{    \}]}
\DoxyCodeLine{  \},}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_pnp_webpack_plugin_README_autotoc_md20433}{}\doxysection{License (\+MIT)}\label{md_sfcode_node_modules_pnp_webpack_plugin_README_autotoc_md20433}
\begin{quote}
{\bfseries{Copyright © 2016 Maël Nison}}

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \char`\"{}\+Software\char`\"{}), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions\+:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED \char`\"{}\+AS IS\char`\"{}, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \end{quote}
