Skip to content

Commit

Permalink
feat: add js file to imported style file
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfBramble committed Sep 9, 2020
1 parent 6fd05e2 commit 190f273
Show file tree
Hide file tree
Showing 8 changed files with 4,720 additions and 3,905 deletions.
55 changes: 34 additions & 21 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@

module.exports = {
presets: [
[
"@babel/preset-env",
{
modules: false
}
],
"@babel/preset-react",
"@babel/preset-typescript"
const config = {
presets: [
[
'@babel/preset-env',
{
modules: false,
},
],
plugins: [
"@babel/plugin-transform-runtime",
[
"@babel/plugin-proposal-decorators",
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins:
process.env.NODE_ENV === 'production'
? [
'./css-plugin',
[
'@babel/plugin-proposal-decorators',
{
legacy: true,
},
],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-modules-commonjs',
]
: [
[
'@babel/plugin-proposal-decorators',
{
legacy: true
}
legacy: true,
},
],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-modules-commonjs',
],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-modules-commonjs"
]
};
module.exports = config;
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ debug.log
yarn-error.log
package-lock.json
dist/
gulpfile.js
gulpfile.js
index.tsx
17 changes: 17 additions & 0 deletions css-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const t = require('@babel/types');
module.exports = function() {
return {
visitor: {
ImportDeclaration(path) {
const { node } = path;
if (!node) return;
const {
source: { value: libName },
} = node;
if (libName === './style.scss') {
path.replaceWith(t.importDeclaration([], t.stringLiteral('./style.css')));
}
},
},
};
};
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const del = require('del');
const ts = require('gulp-typescript');
const cleanCSS = require('gulp-clean-css');
const rename = require('gulp-rename');
// const tsProject = ts.createProject('./tsconfig.build.json');
const babel = require('gulp-babel');

function outputStyleTask() {
return src(['src/components/**/*.scss'])
Expand Down Expand Up @@ -56,8 +56,8 @@ function jsForScss(data) {
}
function jsForCss(data) {
return src('src/index.tsx')
.pipe(rename('style.tsx'))
.pipe(ts({ target: 'ES5' }))
.pipe(rename('css.tsx'))
.pipe(babel())
.pipe(dest('lib/' + String(data) + '/style/'));
}
exports.default = series(clean, parallel(outputStyleTask, globalSass), globalCss);
Loading

0 comments on commit 190f273

Please sign in to comment.