Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7ed0603
init widget with depencies & widget modeler conf
Jan 28, 2019
0f40f0d
enable having local conf
Jan 28, 2019
bc63995
cleanup boilerplate code
Jan 28, 2019
fb0ade3
set widget name
Jan 28, 2019
e99d8d1
added imports-loader to handle jQuery plugins
Jan 28, 2019
a6f3d5d
imported jquery plugins
Jan 28, 2019
94ae73d
refactored update life cycle method & adding subscription
Jan 28, 2019
2c1f506
cleanup
Jan 28, 2019
c2d2ff2
lower case widget id, to follow app store widget id
Jan 28, 2019
1d5b411
fix typoe USe => use
Jan 28, 2019
05b7cb6
added isMxImage helper
Jan 28, 2019
b6764c6
refactoring is in progress...
Jan 28, 2019
55406ca
deleted old widget, and restructured
Jan 29, 2019
9011992
added test project
Jan 29, 2019
cc6f4a3
set path to test project
Jan 29, 2019
a48109c
ignore some autogenerated test projetc files
Jan 29, 2019
9cba585
cleanup unused imports
Jan 29, 2019
3ae45bb
added test cases - different sizes
Jan 29, 2019
b0c9e67
added dist version to test
Jan 29, 2019
0eedad1
next readme
Jan 29, 2019
6d792f7
next readme
Jan 29, 2019
5c39154
next readme
Jan 29, 2019
edc92ab
next read me
Jan 29, 2019
15167fc
next readme|
Jan 29, 2019
ff0eb1b
added the fixed version of the widget to the module
Jan 29, 2019
be4f5e7
added widget props description
Jan 29, 2019
0b7972f
clean-up & correct typos
Jan 29, 2019
b789192
clean-up & correct typos
Jan 29, 2019
03a5320
added repo issue ref
Jan 29, 2019
8d748b9
bump version --> 1.3.0
Jan 29, 2019
3e36da7
added Cropper 1.3.0 to test & module widgets dirs
Jan 29, 2019
f9ff20c
added Cropper 1.3.0 to test & module widgets dirs
Jan 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .jshintrc

This file was deleted.

9 changes: 9 additions & 0 deletions Cropper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
build/
dist/

test/*
!test/widgets
!test/TestCrop.mpr

.mxlocal.config.js
15 changes: 15 additions & 0 deletions Cropper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cropper
Image Cropping Widget

## Install dependencies

`npm install` or `yarn install`


## Available Scripts

- `npm run dev` or `yarn dev`
will watch for any changes you made and build unoptimized version of your widget with a source map for debugging.

- `npm run build` or `yarn build`
will build an optimized (minified & uglified) version of your widget & no source maps will be genrated.
27 changes: 27 additions & 0 deletions Cropper/conf/paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const path = require('path');
let localConfFilePath = "../.mxlocal.config",
localConf = false;
if (moduleExists(localConfFilePath)) {
localConf = require(localConfFilePath);
}
// if there is a local conf then use it otherwise use the default/general
const mxProjectRootDir = localConf && localConf.mxProjectRootDir ? localConf.mxProjectRootDir : path.join(__dirname, "..", "test");

module.exports = {
srcDir: path.join(__dirname, '..', 'src'),
srcEntry: './src/index.js',
confDir: __dirname,
distDir: path.join(__dirname, '..', 'dist'),
buildDir: path.join(__dirname, '..', 'build'),
mxProjectRootDir,
widgetPackageXML: path.join(__dirname, '..', 'src', 'package.ejs'),
widgetConfigXML: path.join(__dirname, '..', 'src', 'widget.config.ejs')
};

function moduleExists(modulePath) {
try {
return require.resolve(modulePath);
} catch (e) {
return false;
}
}
16 changes: 16 additions & 0 deletions Cropper/conf/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
plugins: [
require('autoprefixer'),
require('postcss-clean'),
require('cssnano')({
preset: [
'default',
{
discardComments: {
removeAll: true
}
}
]
})
]
};
126 changes: 126 additions & 0 deletions Cropper/conf/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
const paths = require('./paths');
const widgetConf = require('./widget.config.json');
const XMLPlugin = require('xml-webpack-plugin');
const ArchivePlugin = require('webpack-archive-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const fs = require('fs-extra');

const MODES = {
DEV: 'development',
PROD: 'production'
};
const isProd = process.env.MODE === MODES.PROD;
const isDev = process.env.MODE === MODES.DEV;

const widgetDir = `${widgetConf.name}/widget`;
const widgetUIDir = `${widgetDir}/ui`;

const widgetXMLFiles = [
{
template: paths.widgetPackageXML,
filename: `package.xml`,
data: {
NAME: widgetConf.name
}
},
{
template: paths.widgetConfigXML,
filename: `${widgetConf.name}/${widgetConf.name}.xml`,
data: {
NAME: widgetConf.name,
FRIENDLY_NAME: widgetConf.friendlyName,
WIDGET_DESC: widgetConf.description
}
}
];

module.exports = {
mode: isDev ? MODES.DEV : MODES.PROD,
target: 'web',
devtool: isDev ? 'eval-source-map' : false,
watch: isDev,
entry: paths.srcEntry,
output: {
path: isDev ? paths.buildDir : paths.distDir,
filename: `${widgetDir}/${widgetConf.name}.js`,
libraryTarget: 'amd'
},
optimization: {
minimizer: [
new UglifyJsPlugin({
test: /\.js(\?.*)?$/i
})
]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [ '@babel/preset-env' ],
plugins: [ 'add-module-exports' ]
}
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{ loader: 'postcss-loader', options: { config: { path: paths.confDir } } },
'sass-loader'
]
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
name: `[name].[ext]`,
outputPath: `${widgetUIDir}/images`
}
}
]
}
]
},
externals: [
{ MxWidgetBase: 'mxui/widget/_WidgetBase' },
{ dojoBaseDeclare: 'dojo/_base/declare' },
/mx|mxui|mendix|dijit|dojo|require/
],
plugins: _getPlugins()
};

function _getPlugins() {
//ensure distDir fir Archive Plugin
fs.ensureDirSync(paths.distDir);
const plugins = [
new MiniCssExtractPlugin({
filename: `${widgetUIDir}/${widgetConf.name}.css`
}),
new XMLPlugin({
files: widgetXMLFiles
}),
new ArchivePlugin({
output: `${paths.distDir}/${widgetConf.name}`,
format: 'zip',
ext: 'mpk'
})
];
if (paths.mxProjectRootDir) {
plugins.push(
new ArchivePlugin({
output: `${paths.mxProjectRootDir}/widgets/${widgetConf.name}`,
format: 'zip',
ext: 'mpk'
})
);
}
return plugins;
}
5 changes: 5 additions & 0 deletions Cropper/conf/widget.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "cropper",
"friendlyName": "Image Cropper",
"description": "Image cropper."
}
Loading