Skip to content

Commit

Permalink
Merge pull request #4 from drolsen/dev
Browse files Browse the repository at this point in the history
Dev 1.1.3 Release
  • Loading branch information
drolsen committed Jan 10, 2022
2 parents 787546f + bc76cef commit 8d92cdc
Show file tree
Hide file tree
Showing 49 changed files with 507 additions and 5,962 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class WebpackJSXExport {
),
(e) => {
if (e) {
console.log(e);
return false;
}
}
Expand Down Expand Up @@ -192,7 +193,7 @@ class WebpackJSXExport {
}

// Requested path + input JSX filename + input JSX file extension
output = path.resolve(__dirname, `${output}/${path.basename(i)}`);
output = path.resolve(__dirname, `${output}/${path.basename(i).toLowerCase()}`);
}

// Output path is FILE (aka we are requesting a custom filename for export)
Expand All @@ -207,14 +208,15 @@ class WebpackJSXExport {

// Requested path + input JSX file extension (input JSX file extension used as placeholder)
output = path.resolve(__dirname, `${output}${path.extname(i)}`);
output = output.replace(new RegExp(path.basename(output)), path.basename(output).toLowerCase());
}

// Pass file information to write (note that output replaces .extension with requested .extension).
this.write(
source,
path.basename(output),
path.basename(output).toLowerCase(),
index,
output.replace(new RegExp(path.extname(output)), extension)
output.replace(new RegExp(`\\${path.extname(output)}`, 'g'), extension)
);
}
});
Expand Down
5,596 changes: 0 additions & 5,596 deletions package-lock.json

This file was deleted.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"webpack jsx static export",
"webpack jsx static render export"
],
"version": "1.1.1",
"version": "1.1.3",
"description": "Plugin that bundles project SVG files into a SVG sprite",
"repository": "drolsen/webpack-jsx-export",
"bugs": {
Expand All @@ -20,18 +20,18 @@
"author": "Devin R. Olsen <devin@devinrolsen.com> (http://devinrolsen.com)",
"license": "MIT",
"scripts": {
"test": "npm run basic-test && npm run node-test && npm run conditions-test && npm run extension-test && npm run custom-test && npm run htl-test && npm run razor-test && npm run php-test && npm run glob-test && npm run filter-test && npm run extension-filter-test && npm run ava-test",
"basic-test": "webpack --config ./test/basic.test.config.js --mode production",
"node-test": "node ./test/node.test.js",
"custom-test": "webpack --config ./test/custom.test.config.js --mode production",
"extension-test": "webpack --config ./test/extension.test.config.js --mode production",
"conditions-test": "webpack --config ./test/conditions.test.config.js --mode production",
"htl-test": "webpack --config ./test/htl.test.config.js --mode production",
"razor-test": "webpack --config ./test/razor.test.config.js --mode production",
"php-test": "webpack --config ./test/php.test.config.js --mode production",
"glob-test": "webpack --config ./test/glob.test.config.js --mode production",
"filter-test": "webpack --config ./test/filter.test.config.js --mode production",
"extension-filter-test": "webpack --config ./test/extension-filter.test.config.js --mode production",
"test": "npm run basic-test && npm run conditions-test && npm run extension-test && npm run custom-test && npm run htl-test && npm run razor-test && npm run php-test && npm run glob-test && npm run filter-test && npm run extension-filter-test && npm run node-test && npm run ava-test",
"basic-test": "webpack --config ./test/basic/basic.test.config.js --mode production",
"custom-test": "webpack --config ./test/custom/custom.test.config.js --mode production",
"extension-test": "webpack --config ./test/extensions/extension.test.config.js --mode production",
"conditions-test": "webpack --config ./test/conditions/conditions.test.config.js --mode production",
"htl-test": "webpack --config ./test/plugins/htl.test.config.js --mode production",
"razor-test": "webpack --config ./test/plugins/razor.test.config.js --mode production",
"php-test": "webpack --config ./test/plugins/php.test.config.js --mode production",
"glob-test": "webpack --config ./test/glob/glob.test.config.js --mode production",
"filter-test": "webpack --config ./test/filtering/filter.test.config.js --mode production",
"extension-filter-test": "webpack --config ./test/extensions/extension-filter.test.config.js --mode production",
"node-test": "node ./test/node/node.test.js",
"ava-test": "ava ./test/ava.test.js"
},
"engines": {
Expand Down Expand Up @@ -63,7 +63,7 @@
"pretty": "2.0.0"
},
"devDependencies": {
"ava": "^3.15.0",
"ava": "^4.0.1",
"clean-webpack-plugin": "^4.0.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "5.5.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Allows for <export> and <no-export> tags in JSX source.
// Allows for <export> and <no-export> tags in JSX sources.

const Conditions = (options = {}) => {
options = Object.assign({}, {});
Expand Down
2 changes: 1 addition & 1 deletion plugins/HTL.plugin.js → plugins/htl.plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Adobe Sightly HTL JSX export plugin
// Adobe Sightly HTL JSX export plugins

const HTL = (options = {}) => {
options = Object.assign({}, {});
Expand Down
2 changes: 1 addition & 1 deletion plugins/PHP.plugin.js → plugins/php.plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PHP JSX export plugin
// PHP JSX export plugins

const PHP = (options = {}) => {
options = Object.assign({}, {});
Expand Down
2 changes: 1 addition & 1 deletion plugins/Razor.plugin.js → plugins/razor.plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// .NET Razor JSX export plugin
// .NET Razor JSX export plugins

const Razor = (options = {}) => {
options = Object.assign({}, {});
Expand Down
63 changes: 34 additions & 29 deletions test/ava.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const test = require('ava');
const fs = require('fs');
const path = require('path');
test('basic', t => {
const pass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/Basic.html'), 'utf8');

test('basic-test', t => {
const pass = fs.existsSync(path.resolve(__dirname, './../dist/basic.html'));

if (pass) {
t.pass();
Expand All @@ -12,10 +12,10 @@ test('basic', t => {
}
});

test('Conditions', t => {
let pass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/Conditions.html'), 'utf8');
test('conditions-test', t => {
let pass = fs.readFileSync(path.resolve(__dirname, './../dist/conditions.html'), 'utf8');

if (pass.indexOf('<export>') !== -1 || pass.indexOf('<no-export>') !== -1) {
if (pass.toString().indexOf('<export>') !== -1 || pass.toString().indexOf('<no-export>') !== -1) {
pass = false;
}

Expand All @@ -26,8 +26,8 @@ test('Conditions', t => {
}
});

test('node', t => {
const pass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/node.html'), 'utf8');
test('node-test', t => {
const pass = fs.existsSync(path.resolve(__dirname, './../dist/node.html'));

if (pass) {
t.pass();
Expand All @@ -36,8 +36,8 @@ test('node', t => {
}
});

test('custom', t => {
const pass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/custom.html'), 'utf8');
test('custom-test', t => {
const pass = fs.existsSync(path.resolve(__dirname, './../dist/custom.html'));

if (pass) {
t.pass();
Expand All @@ -46,12 +46,8 @@ test('custom', t => {
}
});

test('HTL', t => {
const pass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/HTL.html'), 'utf8');

if (pass.indexOf('data-sly-') === -1) {
pass = false;
}
test('custom-extension', t => {
const pass = fs.existsSync(path.resolve(__dirname, './../dist/custom.handlebars'));

if (pass) {
t.pass();
Expand All @@ -60,10 +56,10 @@ test('HTL', t => {
}
});

test('Razor', t => {
const pass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/Razor.cshtml'), 'utf8');
test('htl-test', t => {
let pass = fs.readFileSync(path.resolve(__dirname, './../dist/htl.html'), 'utf8');

if (pass.indexOf('@model ') === -1) {
if (pass.toString().indexOf('data-sly-') === -1) {
pass = false;
}

Expand All @@ -74,8 +70,8 @@ test('Razor', t => {
}
});

test('PHP', t => {
const pass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/PHP.php'), 'utf8');
test('razor-test', t => {
const pass = fs.existsSync(path.resolve(__dirname, './../dist//razor.cshtml'));

if (pass) {
t.pass();
Expand All @@ -84,9 +80,19 @@ test('PHP', t => {
}
});

test('glob', t => {
const BasicPass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/glob/Basic.html'), 'utf8');
const HTLPass = fs.readFileSync(path.resolve(__dirname, '../dist/exported/glob/HTL.html'), 'utf8');
test('php-test', t => {
const pass = fs.existsSync(path.resolve(__dirname, './../dist/php.php'));

if (pass) {
t.pass();
} else {
t.fail();
}
});

test('glob-test', t => {
const BasicPass = fs.existsSync(path.resolve(__dirname, './../dist/glob/basic.html'));
const HTLPass = fs.existsSync(path.resolve(__dirname, './../dist/glob/htl.html'));

if (BasicPass && HTLPass) {
t.pass();
Expand All @@ -95,10 +101,10 @@ test('glob', t => {
}
});

test('filter', t => {
test('filter-test', t => {
let pass = false;

if (!fs.existsSync(path.resolve(__dirname, '../dist/exported/filter/Razor.html'))) {
if (!fs.existsSync(path.resolve(__dirname, './../dist/filter/razor.html'))) {
pass = true;
}

Expand All @@ -109,10 +115,10 @@ test('filter', t => {
}
});

test('extension-filter', t => {
test('extension-filter-test', t => {
let pass = false;

if (!fs.existsSync(path.resolve(__dirname, '../dist/exported/filter/Razor.cshtml'))) {
if (!fs.existsSync(path.resolve(__dirname, './../dist/filter/razor.cshtml'))) {
pass = true;
}

Expand All @@ -122,4 +128,3 @@ test('extension-filter', t => {
t.fail();
}
});

25 changes: 0 additions & 25 deletions test/basic.test.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/Basic.jsx → test/basic/basic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The container element also comes with a large number of layout control form Flex to CSS grids.
*/

import Container from './elements/Container.jsx';
import Container from '../elements/container.jsx';

export default (
<Container>
Expand Down
25 changes: 25 additions & 0 deletions test/basic/basic.test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const WebpackJSXExport = require('../../index.js');
const path = require('path');

const config = {
entry: path.resolve(__dirname, '../dummy-entry.js'),
output: {
path: path.resolve(__dirname, '../../dist'),
filename: '[name].js'
},
optimization: {
minimize: false
}
};

module.exports = (env, argv) => {
config.plugins = [
new WebpackJSXExport({
files: [{
input: './test/basic/basic.jsx',
output: './dist/'
}]
})
];
return config;
};
29 changes: 0 additions & 29 deletions test/conditions.test.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/PHP.jsx → test/conditions/conditions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The container element also comes with a large number of layout control form Flex to CSS grids.
*/

import Container from './elements/Container.jsx';
import Container from '../elements/container.jsx';

export default (
<Container>
Expand Down
29 changes: 29 additions & 0 deletions test/conditions/conditions.test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const WebpackJSXExport = require('../../index.js');
const conditions = require('../../plugins/conditions.plugin.js');
const path = require('path');

const config = {
entry: path.resolve(__dirname, '../dummy-entry.js'),
output: {
path: path.resolve(__dirname, '../../dist'),
filename: '[name].js'
},
optimization: {
minimize: false
}
};

module.exports = (env, argv) => {
config.plugins = [
new WebpackJSXExport({
files: [{
input: './test/conditions/conditions.jsx',
output: './dist/'
}],
plugins: {
output: [conditions]
}
})
];
return config;
};

0 comments on commit 8d92cdc

Please sign in to comment.