-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
2,383 additions
and
1,546 deletions.
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
plugins: [require('autoprefixer')], | ||
}; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
// eslint-disable-next-line no-underscore-dangle | ||
const __filename = fileURLToPath(import.meta.url); | ||
|
||
// eslint-disable-next-line no-underscore-dangle | ||
const __dirname = path.dirname(__filename); | ||
|
||
export const getDirNames = (_path) => | ||
!fs.existsSync(_path) | ||
? [] | ||
: fs | ||
.readdirSync(_path, { withFileTypes: true }) | ||
.filter(Boolean) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name); | ||
|
||
const getFilesNames = (_path) => | ||
!fs.existsSync(_path) | ||
? [] | ||
: fs | ||
.readdirSync(_path, { withFileTypes: true }) | ||
.filter(Boolean) | ||
.filter((dirent) => dirent.isFile()) | ||
.map((dirent) => dirent.name); | ||
|
||
export const makeInputsBySource = (source, extList = [], filterCb = null) => { | ||
if (!fs.existsSync(source)) { | ||
return {}; | ||
} | ||
|
||
return getFilesNames(source) | ||
.filter((name) => { | ||
const isRelatedFile = extList.includes(path.parse(name).ext); | ||
const isFilteredFile = filterCb ? filterCb(name) : true; | ||
|
||
return isRelatedFile && isFilteredFile; | ||
}) | ||
.map((name) => path.resolve(__dirname, source, name)); | ||
}; | ||
|
||
export const makeJsInputs = (source) => makeInputsBySource(source, ['.js']); | ||
|
||
export const makeTemplatesInputs = (templatesSource) => { | ||
if (!fs.existsSync(templatesSource)) { | ||
return {}; | ||
} | ||
|
||
return getDirNames(templatesSource) | ||
.filter((name) => name !== 'common') | ||
.reduce( | ||
(res, dirName) => { | ||
( | ||
makeInputsBySource( | ||
path.resolve(templatesSource, dirName), | ||
['.js', '.scss'], | ||
(name) => name.includes(dirName) | ||
) || [] | ||
).forEach((file) => { | ||
if (file.includes('.js')) { | ||
res.js.push(file); | ||
} | ||
|
||
if (file.includes('.scss')) { | ||
res.scss.push(file); | ||
} | ||
}); | ||
|
||
return res; | ||
}, | ||
{ js: [], scss: [] } | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// import multiEntry from '@rollup/plugin-multi-entry'; | ||
import sass from 'rollup-plugin-sass'; | ||
import postcss from 'rollup-plugin-postcss'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from "rollup-plugin-commonjs"; | ||
import { | ||
makeJsInputs, | ||
makeTemplatesInputs | ||
} from "./rollup-helpers.js"; | ||
import path from "path"; | ||
|
||
|
||
const postcssPluginsSet = makeTemplatesInputs('src/templates').scss.map((file) => { | ||
const extractName = `${path.parse(file).name}.css`; | ||
|
||
console.log('___', file, extractName) | ||
|
||
return postcss({ | ||
include: file, | ||
extract: extractName, | ||
use: ['sass'] | ||
}); | ||
}) | ||
|
||
export default { | ||
input: [ | ||
...makeTemplatesInputs('src/templates').js, | ||
...makeJsInputs('src/scripts') | ||
], | ||
output: { | ||
dir: 'dist/assets', | ||
}, | ||
plugins: [ | ||
// postcss({ | ||
// include: "src/templates/article/article.scss", | ||
// extract: 'article.css', | ||
// use: ['sass'] | ||
// }), | ||
...postcssPluginsSet, | ||
sass(), | ||
commonjs({ | ||
include: "node_modules/**", | ||
namedExports: { | ||
// "./node_modules/react/index.js": [ | ||
// "cloneElement", | ||
// "createElement", | ||
// "PropTypes", | ||
// "Children", | ||
// "Component", | ||
// "createFactory", | ||
// "PureComponent", | ||
// "lazy", | ||
// "Suspense", | ||
// "useState", | ||
// "useEffect", | ||
// ], | ||
// "./node_modules/react-dom/index.js": ["findDOMNode"], | ||
// "./node_modules/babel-runtime/node_modules/core-js/library/modules/es6.object.to-string.js": [ | ||
// "default", | ||
// ], | ||
// "./node_modules/process/browser.js": ["nextTick"], | ||
// "./node_modules/events/events.js": ["EventEmitter"], | ||
// "./node_modules/react-is/index.js": ["isValidElementType"], | ||
}, | ||
}), | ||
resolve() | ||
], | ||
}; |