mirror of
https://github.com/codex-team/editor.js
synced 2024-05-17 22:06:49 +02:00
bcdfcdadbc
* Move all modules to ts * It works * Update README.md Co-Authored-By: gohabereg <gohabereg@users.noreply.github.com> * Interfaces * Interfaces * Move depending interfaces to external types * Update README.md * update tools * add some docs * Add some fixes * Add desctiprion for Block declaration and Core properties * Fixes due comments : * Remove Block from external types * Bump version * Update src/components/modules/tools.ts Co-Authored-By: gohabereg <gohabereg@users.noreply.github.com> * Update src/components/core.ts Co-Authored-By: gohabereg <gohabereg@users.noreply.github.com> * Rename gteBlockHTMLByIndex to getBlockByIndex * Remove unnecessary constructors * Clean up bindEvents method * Add InlineToolConstructable interface * Delete legacy notifications class * Fix zero-configuration bugs * Update inline tools and block tunes constructors
160 lines
3.4 KiB
JavaScript
160 lines
3.4 KiB
JavaScript
/**
|
|
* Webpack configuration
|
|
*
|
|
* @author Codex Team
|
|
* @copyright Khaydarov Murod
|
|
*/
|
|
'use strict';
|
|
|
|
const pkg = require('./package.json');
|
|
const path = require('path');
|
|
|
|
/**
|
|
* Environment
|
|
* @type {any}
|
|
*/
|
|
const NODE_ENV = process.env.NODE_ENV || 'development';
|
|
const VERSION = process.env.VERSION || pkg.version;
|
|
|
|
/**
|
|
* Plugins for bundle
|
|
* @type {webpack}
|
|
*/
|
|
const webpack = require('webpack');
|
|
|
|
/**
|
|
* Options for the Babel
|
|
*/
|
|
const babelLoader = {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
cacheDirectory: true,
|
|
plugins: [
|
|
/**
|
|
* Dont need to use «.default» after «export default Class Ui {}»
|
|
* @see {@link https://github.com/59naga/babel-plugin-add-module-exports}
|
|
*/
|
|
// 'add-module-exports',
|
|
/**
|
|
* Babel transforms some awesome ES6 features to ES5 with extra code, such as Class, JSX.
|
|
* This plugin makes all generated extra codes to one module which significantly reduces the bundle code size.
|
|
*
|
|
* {@link https://github.com/brianZeng/babel-plugin-transform-helper}
|
|
* @since 11 dec 2017 - removed due to plugin does not supports class inheritance
|
|
*/
|
|
// ['babel-plugin-transform-helper', {
|
|
// helperFilename:'build/__tmp_babel_helpers.js'
|
|
// }],
|
|
// 'class-display-name',
|
|
]
|
|
}
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
|
'codex-editor': ['@babel/polyfill/noConflict', './src/codex.ts']
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'build'),
|
|
filename: '[name].js',
|
|
library: [ 'CodexEditor' ],
|
|
libraryTarget: 'umd'
|
|
},
|
|
|
|
watch: true,
|
|
watchOptions: {
|
|
aggregateTimeout: 50
|
|
},
|
|
|
|
devtool: NODE_ENV === 'development' ? 'source-map' : null,
|
|
|
|
/**
|
|
* Tell webpack what directories should be searched when resolving modules.
|
|
*/
|
|
resolve : {
|
|
modules : [path.join(__dirname, 'src'), 'node_modules'],
|
|
extensions: ['.js', '.ts'],
|
|
alias: {
|
|
'utils': path.resolve(__dirname + '/src/components/', './utils'),
|
|
'dom': path.resolve(__dirname + '/src/components/', './dom'),
|
|
}
|
|
},
|
|
|
|
plugins: [
|
|
|
|
/** Pass variables into modules */
|
|
new webpack.DefinePlugin({
|
|
NODE_ENV: JSON.stringify(NODE_ENV),
|
|
VERSION: JSON.stringify(VERSION)
|
|
}),
|
|
|
|
/** Block biuld if errors found */
|
|
// new webpack.NoErrorsPlugin(),
|
|
|
|
],
|
|
|
|
module : {
|
|
rules : [
|
|
{
|
|
test: /\.ts$/,
|
|
use: [
|
|
babelLoader,
|
|
{
|
|
loader: 'ts-loader'
|
|
},
|
|
{
|
|
loader: 'tslint-loader',
|
|
options: {
|
|
fix: true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test : /\.js$/,
|
|
use: [
|
|
babelLoader,
|
|
{
|
|
loader: 'eslint-loader?fix=true&esModules=true',
|
|
}
|
|
],
|
|
exclude: [
|
|
/(node_modules|build)/, // dont need to look in '/build' to prevent analyse __tmp_babel_helper.js
|
|
/src[\\\/]components[\\\/]tools/
|
|
]
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
// minimize: 1,
|
|
importLoaders: 1
|
|
}
|
|
},
|
|
'postcss-loader'
|
|
]
|
|
},
|
|
{
|
|
test: /\.(svg)$/,
|
|
use: [
|
|
{
|
|
loader: 'raw-loader',
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
externals: {
|
|
svg: '../src/components/modules/svg.ts'
|
|
},
|
|
optimization: {
|
|
minimize: true
|
|
},
|
|
};
|