feature(package) webpack v4.0.0

This commit is contained in:
coderaiser 2018-02-26 10:11:46 +02:00
parent 0a8ed76315
commit 73ae281bba
6 changed files with 552 additions and 27 deletions

View file

@ -9,7 +9,7 @@ window.exec = require('execon');
// prevent additional loading of emitify
window.Emitify = require('emitify/legacy');
window.CloudCmd = (config) => {
module.exports = window.CloudCmd = (config) => {
window.Promise = window.Promise || require('es6-promise');
window.Util = require('../common/util');
window.CloudFunc = require('../common/cloudfunc');

View file

@ -1,9 +1,8 @@
/* global CloudCmd */
/* global DOM */
'use strict';
const DOM = require('./');
const Images = module.exports;
const LOADING = 'loading';

530
cloudcmd.js Normal file

File diff suppressed because one or more lines are too long

View file

@ -31,7 +31,8 @@
<button id=shift~ class="cmd-button reduce-text icon-terminal" title="Terminal" >⇧ ~</button>
<button id=contact class="cmd-button reduce-text icon-contact" title="Contact" ></button>
</div>
<script src="{{ prefix }}/cloudcmd.js"></script>
<script src="{{ prefix }}/dist/cloudcmd.common.js"></script>
<script src="{{ prefix }}/dist/cloudcmd.js"></script>
<script>
CloudCmd({{ config }});
</script>

View file

@ -83,8 +83,9 @@
"docker:rm-old": "redrun -P docker:rm:*",
"coverage": "nyc npm test",
"report": "nyc report --reporter=text-lcov | coveralls",
"6to5:client": "webpack --progress",
"6to5:client:dev": "NODE_ENV=development redrun 6to5:client",
"6to5": "webpack --progress",
"6to5:client": "npm run 6to5 -- --mode production",
"6to5:client:dev": "NODE_ENV=development npm run 6to5 -- --progress --mode development",
"watch:client": "redrun 6to5:client -- --watch",
"watch:client:dev": "redrun 6to5:client:dev -- --watch",
"watch:server": "nodemon bin/cloudcmd.js",
@ -168,13 +169,12 @@
"es6-promise": "^4.0.5",
"eslint": "^4.0.0",
"eslint-plugin-node": "^6.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
"file-loader": "^1.1.4",
"fresh-require": "^1.0.3",
"gunzip-maybe": "^1.3.1",
"html-looks-like": "^1.0.2",
"html-webpack-exclude-assets-plugin": "^0.0.5",
"html-webpack-plugin": "^2.29.0",
"html-webpack-plugin": "webpack-contrib/html-webpack-plugin",
"limier": "^1.0.1",
"minor": "^1.2.2",
"mock-require": "^3.0.1",
@ -199,7 +199,8 @@
"tar-stream": "^1.5.2",
"url-loader": "^0.6.1",
"version-io": "^2.0.1",
"webpack": "^3.0.0",
"webpack": "^4.0.0",
"webpack-cli": "^2.0.9",
"yaspeller": "^4.0.0"
},
"engines": {

View file

@ -1,10 +1,6 @@
'use strict';
const path = require('path');
const webpack = require('webpack');
const {optimize} = webpack;
const {UglifyJsPlugin} = optimize;
const dir = './client';
const dirModules = './client/modules';
const modules = './modules';
@ -21,7 +17,6 @@ const clean = (array) => array.filter(notEmpty);
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin');
const extractMain = new ExtractTextPlugin('[name].css');
const extractNojs = new ExtractTextPlugin('nojs.css');
@ -29,26 +24,17 @@ const extractNojs = new ExtractTextPlugin('nojs.css');
const extractView = new ExtractTextPlugin('view.css');
const extractConfig = new ExtractTextPlugin('config.css');
const plugins = clean([
!isDev && new UglifyJsPlugin({
sourceMap: true,
comments: false,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'cloudcmd',
filename: 'cloudcmd.js',
}),
const plugins = [
new HtmlWebpackPlugin({
inject: false,
template: 'html/index.html',
minify: !isDev && getMinifyHtmlOptions(),
excludeAssets: [/\\*/],
}),
new HtmlWebpackExcludeAssetsPlugin(),
extractMain,
extractNojs,
extractView,
extractConfig,
]);
];
const rules = clean([
!isDev && {
@ -71,8 +57,16 @@ const rules = clean([
},
]);
const splitChunks = {
chunks: 'all',
name: 'cloudcmd.common',
};
module.exports = {
devtool,
optimization: {
splitChunks,
},
entry: {
cloudcmd: `${dir}/cloudcmd.js`,
[modules + '/edit']: `${dirModules}/edit.js`,