Permalink
Browse files

fix(plugins): fix plugins build script

  • Loading branch information...
kevinchappell committed Nov 8, 2018
1 parent b13bba3 commit de388bd4a1f73499fcd54a849ef052e520689891
Showing with 36 additions and 96 deletions.
  1. +1 −2 package.json
  2. +31 −40 tools/webpack.plugins.config.js
  3. +4 −54 yarn.lock
@@ -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 ../",
@@ -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",
@@ -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)

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit de388bd

Please sign in to comment.