Upgrade to Webpack 4 - first try

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2018-07-02 22:24:56 +02:00
parent 0017ddd310
commit 29a3813ada
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
7 changed files with 3026 additions and 1413 deletions

View file

@ -1,6 +1,11 @@
{
"presets": [
"es2015"
["env", {
"targets": {
"node": "6",
"uglify": true
}
}]
],
"plugins": [
"transform-runtime"

View file

@ -154,35 +154,40 @@
"url": "https://github.com/hackmdio/codimd.git"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-polyfill": "^6.22.0",
"babel-preset-es2015": "^6.18.0",
"babel-runtime": "^6.20.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-runtime": "^6.26.0",
"copy-webpack-plugin": "^4.5.2",
"css-loader": "^0.28.11",
"doctoc": "^1.3.0",
"ejs-loader": "^0.3.0",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.25.0",
"imports-loader": "^0.7.0",
"json-loader": "^0.5.4",
"ejs-loader": "^0.3.1",
"exports-loader": "^0.7.0",
"expose-loader": "^0.7.5",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^1.1.11",
"html-webpack-loader": "^0.0.5",
"html-webpack-plugin": "^4.0.0-alpha",
"imports-loader": "^0.8.0",
"jsonlint": "^1.6.2",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"optimize-css-assets-webpack-plugin": "^1.3.0",
"script-loader": "^0.7.0",
"less-loader": "^4.1.0",
"mini-css-extract-plugin": "^0.4.1",
"optimize-css-assets-webpack-plugin": "^4.0.3",
"script-loader": "^0.7.2",
"standard": "^9.0.1",
"string-loader": "^0.0.1",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.14.0",
"webpack-parallel-uglify-plugin": "^0.2.0"
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"url-loader": "^1.0.1",
"webpack": "^4.14.0",
"webpack-cli": "^3.0.8",
"webpack-parallel-uglify-plugin": "^1.1.0"
},
"standard": {
"globals": [

View file

@ -1,3 +1,3 @@
<% for (var css in htmlWebpackPlugin.files.css) { %>
<link href="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
<link href="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.css[css].path %>" rel="stylesheet">
<% } %>

View file

@ -1,4 +1,4 @@
<script src="<%= webpackConfig.output.baseUrl %>/config"></script>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.chunks[chunk].entry %>" defer></script>
<% for (var js in htmlWebpackPlugin.files.js) { %>
<script src="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.js[js].path %>" defer></script>
<% } %>

View file

@ -3,7 +3,8 @@ var webpack = require('webpack')
var path = require('path')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
var ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = [Object.assign({}, baseConfig, {
plugins: baseConfig.plugins.concat([
@ -11,44 +12,33 @@ module.exports = [Object.assign({}, baseConfig, {
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new ParallelUglifyPlugin({
uglifyJS: {
compress: {
warnings: false
},
output: {
max_line_len: 1000000
},
mangle: false,
sourceMap: false
}
}),
new ExtractTextPlugin('[name].[hash].css')
})
]),
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
cache: true
})
],
splitChunks: {
chunks: 'async',
minChunks: Infinity
}
},
output: {
path: path.join(__dirname, 'public/build'),
publicPath: '/build/',
filename: '[id].[name].[hash].js',
baseUrl: '<%- url %>'
filename: '[id].[name].[hash].js'
// baseUrl: '<%- url %>'
}
}), {
entry: {
htmlExport: path.join(__dirname, 'public/js/htmlExport.js')
},
module: {
loaders: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'sass-loader')
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'less-loader')
}]
},
output: {
path: path.join(__dirname, 'public/build'),
publicPath: '/build/',
@ -61,6 +51,16 @@ module.exports = [Object.assign({}, baseConfig, {
}
}),
new ExtractTextPlugin('html.min.css'),
new OptimizeCssAssetsPlugin()
]
new OptimizeCssAssetsPlugin(),
new MiniCssExtractPlugin()
],
module: {
rules: [{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}]
}
}]

View file

@ -1,8 +1,8 @@
var webpack = require('webpack')
var path = require('path')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
// Fix possible nofile-issues
var fs = require('fs')
@ -21,14 +21,6 @@ module.exports = {
'moment': 'moment',
'Handlebars': 'handlebars'
}),
new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.optimize.CommonsChunkPlugin({
names: ['cover', 'index', 'pretty', 'slide', 'vendor'],
children: true,
async: true,
filename: '[name].js',
minChunks: Infinity
}),
new HtmlWebpackPlugin({
template: 'public/views/includes/header.ejs',
chunks: ['font', 'index-styles', 'index'],
@ -162,15 +154,17 @@ module.exports = {
from: 'plugin',
to: 'reveal.js/plugin'
}
])
]),
new MiniCssExtractPlugin()
],
entry: {
font: path.join(__dirname, 'public/css/google-font.css'),
'font-pack': path.join(__dirname, 'public/css/font.css'),
common: [
'expose?jQuery!expose?$!jquery',
'expose-loader?jQuery!expose-loader?$!jquery',
'velocity-animate',
'imports?$=jquery!jquery-mousewheel',
'imports-loader?$=jquery!jquery-mousewheel',
'bootstrap'
],
cover: [
@ -187,27 +181,27 @@ module.exports = {
'cover-pack': [
'babel-polyfill',
'bootstrap-validator',
'expose?select2!select2',
'expose?moment!moment',
'script!js-url',
'expose-loader?select2!select2',
'expose-loader?moment!moment',
'script-loader!js-url',
path.join(__dirname, 'public/js/cover.js')
],
index: [
'babel-polyfill',
'script!jquery-ui-resizable',
'script!js-url',
'expose?filterXSS!xss',
'script!Idle.Js',
'expose?LZString!lz-string',
'script!codemirror',
'script!inlineAttachment',
'script!jqueryTextcomplete',
'script!codemirrorSpellChecker',
'script!codemirrorInlineAttachment',
'script!ot',
'script-loader!jquery-ui-resizable',
'script-loader!js-url',
'expose-loader?filterXSS!xss',
'script-loader!Idle.Js',
'expose-loader?LZString!lz-string',
'script-loader!codemirror',
'script-loader!inlineAttachment',
'script-loader!jqueryTextcomplete',
'script-loader!codemirrorSpellChecker',
'script-loader!codemirrorInlineAttachment',
'script-loader!ot',
'flowchart.js',
'js-sequence-diagrams',
'expose?RevealMarkdown!reveal-markdown',
'expose-loader?RevealMarkdown!reveal-markdown',
path.join(__dirname, 'public/js/index.js')
],
'index-styles': [
@ -238,40 +232,40 @@ module.exports = {
],
'index-pack': [
'babel-polyfill',
'expose?Spinner!spin.js',
'script!jquery-ui-resizable',
'expose-loader?Spinner!spin.js',
'script-loader!jquery-ui-resizable',
'bootstrap-validator',
'expose?jsyaml!js-yaml',
'script!mermaid',
'expose?moment!moment',
'script!js-url',
'script!handlebars',
'expose?hljs!highlight.js',
'expose?emojify!emojify.js',
'expose?filterXSS!xss',
'script!Idle.Js',
'script!gist-embed',
'expose?LZString!lz-string',
'script!codemirror',
'script!inlineAttachment',
'script!jqueryTextcomplete',
'script!codemirrorSpellChecker',
'script!codemirrorInlineAttachment',
'script!ot',
'expose-loader?jsyaml!js-yaml',
'script-loader!mermaid',
'expose-loader?moment!moment',
'script-loader!js-url',
'script-loader!handlebars',
'expose-loader?hljs!highlight.js',
'expose-loader?emojify!emojify.js',
'expose-loader?filterXSS!xss',
'script-loader!Idle.Js',
'script-loader!gist-embed',
'expose-loader?LZString!lz-string',
'script-loader!codemirror',
'script-loader!inlineAttachment',
'script-loader!jqueryTextcomplete',
'script-loader!codemirrorSpellChecker',
'script-loader!codemirrorInlineAttachment',
'script-loader!ot',
'flowchart.js',
'js-sequence-diagrams',
'expose?Viz!viz.js',
'script!abcjs',
'expose?io!socket.io-client',
'expose?RevealMarkdown!reveal-markdown',
'expose-loader?Viz!viz.js',
'script-loader!abcjs',
'expose-loader?io!socket.io-client',
'expose-loader?RevealMarkdown!reveal-markdown',
path.join(__dirname, 'public/js/index.js')
],
pretty: [
'babel-polyfill',
'expose?filterXSS!xss',
'expose-loader?filterXSS!xss',
'flowchart.js',
'js-sequence-diagrams',
'expose?RevealMarkdown!reveal-markdown',
'expose-loader?RevealMarkdown!reveal-markdown',
path.join(__dirname, 'public/js/pretty.js')
],
'pretty-styles': [
@ -288,28 +282,28 @@ module.exports = {
],
'pretty-pack': [
'babel-polyfill',
'expose?jsyaml!js-yaml',
'script!mermaid',
'expose?moment!moment',
'script!handlebars',
'expose?hljs!highlight.js',
'expose?emojify!emojify.js',
'expose?filterXSS!xss',
'script!gist-embed',
'expose-loader?jsyaml!js-yaml',
'script-loader!mermaid',
'expose-loader?moment!moment',
'script-loader!handlebars',
'expose-loader?hljs!highlight.js',
'expose-loader?emojify!emojify.js',
'expose-loader?filterXSS!xss',
'script-loader!gist-embed',
'flowchart.js',
'js-sequence-diagrams',
'expose?Viz!viz.js',
'script!abcjs',
'expose?RevealMarkdown!reveal-markdown',
'expose-loader?Viz!viz.js',
'script-loader!abcjs',
'expose-loader?RevealMarkdown!reveal-markdown',
path.join(__dirname, 'public/js/pretty.js')
],
slide: [
'babel-polyfill',
'bootstrap-tooltip',
'expose?filterXSS!xss',
'expose-loader?filterXSS!xss',
'flowchart.js',
'js-sequence-diagrams',
'expose?RevealMarkdown!reveal-markdown',
'expose-loader?RevealMarkdown!reveal-markdown',
path.join(__dirname, 'public/js/slide.js')
],
'slide-styles': [
@ -325,25 +319,25 @@ module.exports = {
],
'slide-pack': [
'babel-polyfill',
'expose?jQuery!expose?$!jquery',
'expose-loader?jQuery!expose-loader?$!jquery',
'velocity-animate',
'imports?$=jquery!jquery-mousewheel',
'imports-loader?$=jquery!jquery-mousewheel',
'bootstrap-tooltip',
'expose?jsyaml!js-yaml',
'script!mermaid',
'expose?moment!moment',
'script!handlebars',
'expose?hljs!highlight.js',
'expose?emojify!emojify.js',
'expose?filterXSS!xss',
'script!gist-embed',
'expose-loader?jsyaml!js-yaml',
'script-loader!mermaid',
'expose-loader?moment!moment',
'script-loader!handlebars',
'expose-loader?hljs!highlight.js',
'expose-loader?emojify!emojify.js',
'expose-loader?filterXSS!xss',
'script-loader!gist-embed',
'flowchart.js',
'js-sequence-diagrams',
'expose?Viz!viz.js',
'script!abcjs',
'expose-loader?Viz!viz.js',
'script-loader!abcjs',
'headjs',
'expose?Reveal!reveal.js',
'expose?RevealMarkdown!reveal-markdown',
'expose-loader?Reveal!reveal.js',
'expose-loader?RevealMarkdown!reveal-markdown',
path.join(__dirname, 'public/js/slide.js')
]
},
@ -356,8 +350,8 @@ module.exports = {
},
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js'],
modules: ['node_modules'],
extensions: ['.js'],
alias: {
codemirror: path.join(__dirname, 'node_modules/codemirror/codemirror.min.js'),
inlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'),
@ -388,54 +382,82 @@ module.exports = {
},
module: {
loaders: [{
test: /\.json$/,
loader: 'json-loader'
}, {
rules: [{
test: /\.js$/,
loader: 'babel',
use: [{loader: 'babel-loader'}],
exclude: [/node_modules/, /public\/vendor/]
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'sass-loader')
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'sass-loader'
]
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'less-loader')
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1
}
},
'less-loader'
]
}, {
test: require.resolve('js-sequence-diagrams'),
loader: 'imports?_=lodash&Raphael=raphael&eve=eve'
use: [{
loader: 'imports-loader',
options: {_: 'lodash', Raphael: 'raphael', eve: 'eve'}}]
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file'
use: [{loader: 'file-loader'}]
}, {
test: /\.html$/,
loader: 'string'
use: [{loader: 'string-loader'}]
}, {
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?prefix=font/&limit=5000'
use: [{
loader: 'url-loader',
options: {prefix: 'font/', limit: '5000'}}]
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream'
use: [{
loader: 'url-loader',
options: {limit: '5000', mimetype: 'application/octet-stream'}}]
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/svg+xml'
use: [{
loader: 'url-loader',
options: {limit: '10000', mimetype: 'svg+xml'}}]
}, {
test: /\.png(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/png'
use: [{
loader: 'url-loader',
options: {limit: '10000', mimetype: 'image/png'}}]
}, {
test: /\.gif(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/gif'
use: [{
loader: 'url-loader',
options: {limit: '10000', mimetype: 'image/gif'}}]
}]
},
node: {
fs: 'empty'
},
quiet: false,
noInfo: false,
stats: {
assets: false
}

4091
yarn.lock

File diff suppressed because it is too large Load diff