Skip to content

Commit b63775f

Browse files
danielbariongabrieljablonski
authored andcommitted
fix: update rollup-build to output missed normal css file
1 parent a5f8f4b commit b63775f

File tree

1 file changed

+34
-19
lines changed

1 file changed

+34
-19
lines changed

rollup.config.prod.js

+34-19
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ const sharedPlugins = [
4848
'process.env.NODE_ENV': JSON.stringify('development'),
4949
},
5050
}),
51-
postcss({
52-
extract: 'react-tooltip.min.css', // this will generate a specific file and override on multiples build, but the css will be the same
53-
autoModules: true,
54-
include: '**/*.css',
55-
extensions: ['.css'],
56-
plugins: [],
57-
minimize: true,
58-
}),
5951
nodeResolve(),
6052
ts({
6153
typescript,
@@ -68,24 +60,47 @@ const sharedPlugins = [
6860
include: 'node_modules/**',
6961
}),
7062
]
71-
// this step is just to build the minified css and es modules javascript
63+
// this step is just to build the minified javascript files
7264
const minifiedBuildFormats = buildFormats.map(({ file, ...rest }) => ({
7365
file: file.replace(/(\.[cm]?js)$/, '.min$1'),
7466
...rest,
67+
minify: true,
7568
plugins: [terser(), filesize()],
7669
}))
7770

7871
const allBuildFormats = [...buildFormats, ...minifiedBuildFormats]
7972

80-
const config = {
81-
input,
82-
output: allBuildFormats.map((buildFormat) => ({
83-
name,
84-
...buildFormat,
85-
sourcemap: true,
86-
})),
87-
external,
88-
plugins: sharedPlugins,
89-
}
73+
const config = allBuildFormats.map(
74+
({ file, format, globals, plugins: specificPlugins, minify }) => {
75+
const plugins = [
76+
...sharedPlugins,
77+
postcss({
78+
extract: minify ? 'react-tooltip.min.css' : 'react-tooltip.css', // this will generate a specific file and override on multiples build, but the css will be the same
79+
autoModules: true,
80+
include: '**/*.css',
81+
extensions: ['.css'],
82+
plugins: [],
83+
minimize: Boolean(minify),
84+
}),
85+
]
86+
87+
if (specificPlugins && specificPlugins.length) {
88+
plugins.push(...specificPlugins)
89+
}
90+
91+
return {
92+
input,
93+
output: {
94+
file,
95+
format,
96+
name,
97+
globals,
98+
sourcemap: true,
99+
},
100+
external,
101+
plugins,
102+
}
103+
},
104+
)
90105

91106
export default config

0 commit comments

Comments
 (0)