Created
April 4, 2019 02:22
-
-
Save kristoferbaxter/524770bec455c355f352fdd47e81e9be to your computer and use it in GitHub Desktop.
Rollup + Module CSS + TypeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "thing", | |
"version": "0.0.1", | |
"description": "Thing", | |
"main": "dist/media/base.js", | |
"author": "Kristofer Baxter", | |
"license": "Apache-2.0", | |
"scripts": { | |
"clean": "rimraf dist/*", | |
"type-css": "tcm src -s", | |
"tsc": "tsc --build tsconfig.json", | |
"copy-css": "rsync -am --include='*.css' --include='*/' --exclude='*' src/ output/", | |
"premain": "run-s clean type-css tsc copy-css", | |
"main": "rollup --config rollup.config.js" | |
}, | |
"dependencies": { | |
"d3-shape": "1.3.5", | |
"obj-str": "1.0.3", | |
"preact": "8.4.2" | |
}, | |
"devDependencies": { | |
"@ampproject/rollup-plugin-closure-compiler": "0.8.5", | |
"@babel/core": "7.4.0", | |
"@babel/plugin-transform-react-jsx": "7.3.0", | |
"@babel/preset-env": "7.4.2", | |
"@babel/preset-typescript": "7.3.3", | |
"@modular-css/rollup": "22.3.0", | |
"@types/d3-shape": "1.3.1", | |
"babel-plugin-transform-remove-console": "6.9.4", | |
"nodemon": "1.18.10", | |
"npm-run-all": "4.1.5", | |
"postcss-import": "12.0.1", | |
"rimraf": "2.6.3", | |
"rollup": "1.7.0", | |
"rollup-plugin-babel": "4.3.2", | |
"rollup-plugin-copy-glob": "0.3.0", | |
"rollup-plugin-json": "4.0.0", | |
"rollup-plugin-terser": "4.0.4", | |
"rollup-plugin-typescript": "1.0.1", | |
"typed-css-modules": "0.4.2", | |
"typescript": "3.4.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resolve from 'rollup-plugin-node-resolve'; | |
import babel from 'rollup-plugin-babel'; | |
import compiler from '@ampproject/rollup-plugin-closure-compiler'; | |
import { terser } from 'rollup-plugin-terser'; | |
import css from '@modular-css/rollup'; | |
import copy from 'rollup-plugin-copy-glob'; | |
import postCssImport from 'postcss-import'; | |
import json from 'rollup-plugin-json'; | |
const MINIFY_BUNDLE_VALUE = true; | |
export default { | |
input: 'output/base.jsx', | |
output: { | |
file: 'dist/media/base.js', | |
format: 'es', | |
sourcemap: true, | |
assetFileNames: '[name][extname]', | |
}, | |
plugins: [ | |
resolve({ | |
extensions: ['.mjs', '.js', '.jsx', '.json'], | |
}), | |
json(), | |
copy([{ files: 'src/media/**/*.*', dest: 'dist/media' }, { files: 'src/index.html', dest: 'dist' }]), | |
css({ | |
rewrite: false, | |
before: [postCssImport], | |
}), | |
babel({ | |
exclude: 'node_modules/**', | |
presets: [ | |
[ | |
'@babel/env', | |
{ | |
targets: { esmodules: true }, | |
loose: true, | |
modules: false, | |
}, | |
], | |
], | |
plugins: [ | |
[ | |
'@babel/plugin-transform-react-jsx', | |
{ | |
pragma: 'h', | |
}, | |
], | |
['@babel/plugin-proposal-object-rest-spread'], | |
['@babel/proposal-class-properties'], | |
['babel-plugin-transform-remove-console', { exclude: ['log'] }], | |
], | |
}), | |
MINIFY_BUNDLE_VALUE ? compiler() : null, | |
MINIFY_BUNDLE_VALUE ? terser() : null, | |
].filter(Boolean), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment