Skip to content

Instantly share code, notes, and snippets.

@thiporia
Last active February 15, 2021 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiporia/49eb6672ad209ab1a2e05af49dab6a1d to your computer and use it in GitHub Desktop.
Save thiporia/49eb6672ad209ab1a2e05af49dab6a1d to your computer and use it in GitHub Desktop.
basic rollup.config.js with sass
import { babel } from '@rollup/plugin-babel'
import alias from '@rollup/plugin-alias'
import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import postcss from 'rollup-plugin-postcss'
import json from '@rollup/plugin-json'
import url from '@rollup/plugin-url'
import typescript from '@rollup/plugin-typescript'
import pkg from './package.json'
export default {
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
{
file: pkg.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**',
extensions: ['.js', '.ts', '.tsx'],
}),
alias({
entries: [
{ find: '@src', replacement: 'src' },
{ find: '@Styles', replacement: 'src/assets/styles' },
{ find: '@Components', replacement: 'src/components' },
],
}),
postcss({
includePaths: ['src/components', 'src/assets/styles'],
extensions: ['.css', '.scss', '.sass'],
}),
nodeResolve({
mainFields: ['browser', 'jsnext', 'module', 'main'],
}),
commonjs({ extensions: ['.js', '.ts', '.tsx'] }),
url(),
json(),
typescript(),
],
external: [
'react',
'react-dom',
'styled-components',
'typescript',
'tslib',
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment