Skip to content

Commit

Permalink
fix(plugins): fix plugins build script
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Nov 8, 2018
1 parent b13bba3 commit de388bd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 96 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"build:plugins": "webpack --mode production -p --display-entrypoints --progress --config tools/webpack.plugins.config",
"build:vendor": "mkdir -p demo/assets/js/ && node tools/run build-vendor",
"build": "webpack --mode production -p --progress --config tools/webpack.config",
"build:all": "yarn build && yarn build:plugins && yarn build:vendor && yarn copy",
"build:all": "yarn build && yarn build:vendor && yarn build:plugins && yarn copy",
"copy": "cp -a dist/* demo/assets/js/ && cp CONTRIBUTING.md docs/contributing.md && cp LICENSE docs/license.md && mkdir -p demo/assets/lang && cp node_modules/formbuilder-languages/*.lang demo/assets/lang/",
"deploy": "yarn build && node tools/deploy.js",
"deploy:site": "yarn docs && cd site/ && yarn deploy && cd ../",
Expand Down Expand Up @@ -118,7 +118,6 @@
"clui": "0.3.6",
"compression-webpack-plugin": "2.0.0",
"concat-files": "0.1.1",
"copy-webpack-plugin": "4.5.1",
"cross-env": "5.2.0",
"css-loader": "0.28.11",
"eslint": "4.19.1",
Expand Down
71 changes: 31 additions & 40 deletions tools/webpack.plugins.config.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,34 @@
const fs = require('fs');
const {resolve} = require('path');
const pkg = require('../package.json');
const webpackConfig = require('./webpack.config');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const fs = require('fs')
const { resolve } = require('path')
const pkg = require('../package.json')
const webpackConfig = require('./webpack.config')

const pluginsDir = resolve(__dirname, '../', pkg.config.files.pluginsDir);
const outputDir = resolve(__dirname, '../', 'demo/assets/js/control_plugins/');
const root = resolve(__dirname, '../')
const pluginsDir = resolve(__dirname, '../', pkg.config.files.pluginsDir)

webpackConfig.entry = {};
const pluginsConfig = {
plugins: [],
output: {
path: root,
filename: '[name].min.js',
},
entry: () =>
new Promise(resolve => {
const entry = {}
fs.readdir(pluginsDir, (error, files) => {
if (error) {
throw Error(error)
}
files.forEach(file => {
if (file.indexOf('.js') !== -1) {
const pluginName = file.replace('.js', '')
entry[`dist/control_plugins/${pluginName}`] = `${pluginsDir}/${file}`
entry[`demo/assets/js/control_plugins/${pluginName}`] = `${pluginsDir}/${file}`
}
})
resolve(entry)
})
}),
}

webpackConfig.plugins = [
new CopyWebpackPlugin([
{
from: outputDir,
to: resolve(__dirname, '../', 'dist/control_plugins')
}
])
]

webpackConfig.output = {
path: outputDir,
publicPath: '/assets/js/control_plugins',
filename: '[name].min.js'
};

webpackConfig.entry = () => new Promise((resolve) => {
let entry = {};
fs.readdir(pluginsDir, (error, files) => {
if (error) {
throw Error(error)
}
files.forEach(file => {
if (file.indexOf('.js') !== -1) {
let pluginName = file.replace('.js', '');
entry[pluginName] = `${pluginsDir}/${file}`;
}
});
resolve(entry);
});
});

module.exports = webpackConfig;
module.exports = Object.assign({}, webpackConfig, pluginsConfig)
58 changes: 4 additions & 54 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2742,19 +2742,6 @@ copy-descriptor@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"

copy-webpack-plugin@4.5.1:
version "4.5.1"
resolved "http://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-4.5.1.tgz#fc4f68f4add837cc5e13d111b20715793225d29c"
dependencies:
cacache "^10.0.4"
find-cache-dir "^1.0.0"
globby "^7.1.1"
is-glob "^4.0.0"
loader-utils "^1.1.0"
minimatch "^3.0.4"
p-limit "^1.0.0"
serialize-javascript "^1.4.0"

core-js@^2.4.0, core-js@^2.5.0, core-js@^2.5.7:
version "2.5.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e"
Expand Down Expand Up @@ -3028,7 +3015,7 @@ debug@^4.0.0:
dependencies:
ms "^2.1.1"

debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"

Expand Down Expand Up @@ -4253,17 +4240,6 @@ globby@^6.1.0:
pify "^2.0.0"
pinkie-promise "^2.0.0"

globby@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/globby/-/globby-7.1.1.tgz#fb2ccff9401f8600945dfada97440cca972b8680"
dependencies:
array-union "^1.0.1"
dir-glob "^2.0.0"
glob "^7.1.2"
ignore "^3.3.5"
pify "^3.0.0"
slash "^1.0.0"

globby@^8.0.0, globby@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.1.tgz#b5ad48b8aa80b35b814fc1281ecc851f1d2b5b50"
Expand Down Expand Up @@ -4694,7 +4670,7 @@ import-local@^1.0.0:
pkg-dir "^2.0.0"
resolve-cwd "^2.0.0"

imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"

Expand Down Expand Up @@ -5480,39 +5456,17 @@ lockfile@^1.0.4:
dependencies:
signal-exit "^3.0.2"

lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"

lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
dependencies:
lodash._createset "~4.0.0"
lodash._root "~3.0.0"

lodash._bindcallback@*:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"

lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"

lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
dependencies:
lodash._getnative "^3.0.0"

lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"

lodash._getnative@*, lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"

lodash._root@~3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"
Expand Down Expand Up @@ -5557,10 +5511,6 @@ lodash.mergewith@^4.6.0:
version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"

lodash.restparam@*:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"

lodash.tail@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664"
Expand Down Expand Up @@ -6746,7 +6696,7 @@ p-is-promise@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.0.0.tgz#7554e3d572109a87e1f3f53f6a7d85d1b194f4c5"

p-limit@^1.0.0, p-limit@^1.1.0:
p-limit@^1.1.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8"
dependencies:
Expand Down Expand Up @@ -7658,7 +7608,7 @@ readable-stream@~1.1.10:
isarray "0.0.1"
string_decoder "~0.10.x"

readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
dependencies:
Expand Down

0 comments on commit de388bd

Please sign in to comment.