(pathService: Path.Path, options: PluginOptions = {})
| 130 | * @since 4.0.0 |
| 131 | */ |
| 132 | export const createPlugins = (pathService: Path.Path, options: PluginOptions = {}): Array<Plugin> => { |
| 133 | const resolved = resolvePluginOptions(options) |
| 134 | const plugins: Array<Plugin> = [ |
| 135 | createResolveLocalPackageImports(pathService), |
| 136 | nodeResolve(), |
| 137 | // @ts-expect-error see https://github.com/rollup/plugins/issues/1662 |
| 138 | replace({ |
| 139 | "process.env.NODE_ENV": JSON.stringify("production"), |
| 140 | preventAssignment: true |
| 141 | }), |
| 142 | esbuild({ |
| 143 | target: resolved.nodeTarget, |
| 144 | format: "esm", |
| 145 | treeShaking: true |
| 146 | }), |
| 147 | // @ts-expect-error see https://github.com/rollup/plugins/issues/1662 |
| 148 | terser({ |
| 149 | format: { comments: false }, |
| 150 | compress: resolved.minify, |
| 151 | mangle: resolved.mangle && !resolved.visualize |
| 152 | }) |
| 153 | ] |
| 154 | |
| 155 | if (resolved.visualizations.length > 0) { |
| 156 | for (const output of resolved.visualizations) { |
| 157 | const visualizerOptions: PluginVisualizerOptions = { |
| 158 | filename: output.filename, |
| 159 | gzipSize: true, |
| 160 | open: false, |
| 161 | template: output.template |
| 162 | } |
| 163 | if (output.title !== undefined) { |
| 164 | visualizerOptions.title = output.title |
| 165 | } |
| 166 | plugins.push(visualizer(visualizerOptions)) |
| 167 | } |
| 168 | } else if (resolved.visualize) { |
| 169 | plugins.push(visualizer({ |
| 170 | open: true, |
| 171 | gzipSize: true |
| 172 | })) |
| 173 | } |
| 174 | |
| 175 | return plugins |
| 176 | } |
no test coverage detected