Skip to content

Commit

Permalink
feat(react): move from taskr to rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
reel committed Jul 31, 2020
1 parent aeb4280 commit b5a2cd3
Show file tree
Hide file tree
Showing 5 changed files with 2,409 additions and 3,294 deletions.
32 changes: 20 additions & 12 deletions packages/react/engine/conf.js
@@ -1,6 +1,7 @@
const webpack = require('webpack');
const path = require('path');
const glob = require('glob');
const fs = require('fs');
const withSass = require('@zeit/next-sass');
const debug = require('debug')('henri:react');

Expand All @@ -11,16 +12,23 @@ const dir = path.resolve(cwd(), 'app/views');
let userConfig = null;

try {
//eslint-disable-next-line global-require
const conf = require(path.resolve(cwd(), 'config', 'webpack.js'));
const configFilePath = path.resolve(cwd(), 'config', 'webpack.js');

if (typeof conf.webpack === 'function') {
userConfig = conf.webpack;
if (fs.existsSync(configFilePath)) {
//eslint-disable-next-line global-require
const conf = require(configFilePath);

if (typeof conf.webpack === 'function') {
userConfig = conf.webpack;
debug('loaded webpack configuration file to extend next.js config');
} else {
pen.error(
'react',
`Can't load your config/webpack.js file. It should export a function.`
);
}
} else {
pen.error(
'react',
`Can't load your config/webpack.js file. It should export a function.`
);
debug('no custom webpack.js found in the config folder');
}
} catch (err) {
debug('will not load nextjs local config');
Expand All @@ -30,8 +38,8 @@ try {
module.exports = withSass({
sassLoaderOptions: {
includePaths: ['styles', 'node_modules']
.map(dir => path.join(__dirname, dir))
.map(gro => glob.sync(gro))
.map((dir) => path.join(__dirname, dir))
.map((gro) => glob.sync(gro))
.reduce((arr, key) => arr.concat(key), []),
},

Expand All @@ -49,8 +57,8 @@ module.exports = withSass({
loader: 'sass-loader',
options: {
includePaths: ['styles', 'node_modules']
.map(dir => path.join(__dirname, dir))
.map(glo => glob.sync(glo))
.map((dir) => path.join(__dirname, dir))
.map((glo) => glob.sync(glo))
.reduce((arr, key) => arr.concat(key), []),
},
},
Expand Down
45 changes: 20 additions & 25 deletions packages/react/package.json
Expand Up @@ -5,20 +5,14 @@
"main": "index.js",
"author": "Felix-Antoine Paradis",
"license": "MIT",
"private": false,
"scripts": {
"build": "taskr",
"local": "taskr local",
"prepublish": "taskr release"
"build": "rollup -c",
"local": "rollup -c -w",
"prepublish": "rollup -c"
},
"devDependencies": {
"@taskr/babel": "1.1.0-next.1",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/shell": "^1.1.0",
"@taskr/uglify": "1.1.0",
"@taskr/watch": "1.1.0",
"taskr": "1.1.0"
"@rollup/plugin-babel": "^5.1.0",
"rollup": "^2.23.0"
},
"files": [
"dist",
Expand All @@ -27,33 +21,34 @@
"withHenri.js"
],
"dependencies": {
"@babel/core": "7.5.5",
"@babel/plugin-proposal-class-properties": "7.5.5",
"@babel/plugin-proposal-object-rest-spread": "7.5.5",
"@babel/plugin-transform-runtime": "7.5.5",
"@babel/preset-env": "7.5.5",
"@babel/preset-react": "7.0.0",
"axios": "^0.19.1",
"@babel/core": "7.11.0",
"@babel/plugin-proposal-class-properties": "7.10.4",
"@babel/plugin-proposal-object-rest-spread": "7.11.0",
"@babel/plugin-transform-runtime": "7.11.0",
"@babel/preset-env": "7.11.0",
"@babel/preset-react": "7.10.4",
"axios": "^0.19.2",
"babel-core": "7.0.0-bridge.0",
"babel-loader": "8.0.6",
"babel-plugin-module-resolver": "3.2.0",
"babel-loader": "8.1.0",
"babel-plugin-module-resolver": "4.0.0",
"babel-plugin-wrap-in-js": "1.1.1",
"cache-loader": "^4.0.1",
"caniuse-lite": "^1.0.30001020",
"caniuse-lite": "^1.0.30001023",
"cssnano": "^4.1.10",
"debug": "^4.1.1",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"module-alias": "^2.2.2",
"next": "^9.2.0",
"next": "^9.2.1",
"postcss-easy-import": "^3.0.0",
"postcss-loader": "^3.0.0",
"prop-types": "^15.7.2",
"raw-loader": "^3.0.0",
"raw-loader": "^4.0.1",
"react-quill": "^1.3.3",
"sass-loader": "^7.1.0",
"recursive-readdir": "^2.2.2",
"sass-loader": "^9.0.2",
"shallowequal": "^1.1.0",
"socket.io-client": "^2.3.0",
"validator": "^12.1.0"
"validator": "^13.1.1"
}
}
44 changes: 44 additions & 0 deletions packages/react/rollup.config.js
@@ -0,0 +1,44 @@
import babel from '@rollup/plugin-babel';
var recursive = require('recursive-readdir');

async function getFiles() {
const files = await recursive('src');

return files;
}
const external = [
'@babel/runtime/helpers/assertThisInitialized',
'@babel/runtime/helpers/classCallCheck',
'@babel/runtime/helpers/createClass',
'@babel/runtime/helpers/defineProperty',
'@babel/runtime/helpers/extends',
'@babel/runtime/helpers/getPrototypeOf',
'@babel/runtime/helpers/inherits',
'@babel/runtime/helpers/objectWithoutProperties',
'@babel/runtime/helpers/possibleConstructorReturn',
'@babel/runtime/regenerator',
'@babel/runtime/helpers/asyncToGenerator',
'axios',
'core-js',
'react',
'next/router',
'prop-types',
'shallowequal',
'validator',
];

export default getFiles().then((files) =>
files.map((name, index) => ({
external,
input: name,
output: {
dir: name.startsWith('src/forms') ? 'dist/lib/forms' : 'dist/lib',
exports: 'named',
format: 'cjs',
name,
},
plugins: [
babel({ babelHelpers: 'runtime', presets: ['@babel/preset-react'] }),
],
}))
);
29 changes: 0 additions & 29 deletions packages/react/taskfile.js

This file was deleted.

0 comments on commit b5a2cd3

Please sign in to comment.