2016-12-07 19:25:31 +01:00
|
|
|
/**
|
|
|
|
* Webpack configuration
|
|
|
|
*
|
|
|
|
* @author Codex Team
|
|
|
|
* @copyright Khaydarov Murod
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2017-01-10 19:22:40 +01:00
|
|
|
var pkg = require('./package.json');
|
|
|
|
var path = require('path');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Environment
|
|
|
|
* @type {any}
|
|
|
|
*/
|
2016-12-07 19:25:31 +01:00
|
|
|
const NODE_ENV = process.env.NODE_ENV || 'development';
|
2017-01-10 19:22:40 +01:00
|
|
|
const VERSION = process.env.VERSION || pkg.version;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plugins for bundle
|
|
|
|
* @type {webpack}
|
|
|
|
*/
|
|
|
|
var webpack = require('webpack');
|
|
|
|
var ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
|
2016-12-07 19:25:31 +01:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
entry: {
|
2017-11-01 22:27:20 +01:00
|
|
|
'codex-editor': './codex'
|
2016-12-07 19:25:31 +01:00
|
|
|
},
|
|
|
|
output: {
|
2017-11-01 22:27:20 +01:00
|
|
|
filename: '[name].js',
|
|
|
|
library: [ 'CodexEditor' ]
|
2016-12-07 19:25:31 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: true,
|
|
|
|
|
|
|
|
watchOptions: {
|
2017-04-22 23:53:06 +02:00
|
|
|
aggregateTimeOut: 50
|
2016-12-07 19:25:31 +01:00
|
|
|
},
|
|
|
|
|
2017-11-01 22:27:20 +01:00
|
|
|
devtool: NODE_ENV == 'development' ? 'source-map' : null,
|
2016-12-07 19:25:31 +01:00
|
|
|
|
|
|
|
resolve : {
|
2017-11-01 22:27:20 +01:00
|
|
|
fallback: path.join(__dirname, 'node_modules'),
|
|
|
|
modulesDirectories : [ './modules' ],
|
2017-01-10 19:22:40 +01:00
|
|
|
extensions : ['', '.js', '.json']
|
2016-12-07 19:25:31 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
resolveLoader : {
|
2017-11-01 22:27:20 +01:00
|
|
|
modulesDirectories: [ './node_modules' ],
|
|
|
|
moduleTemplates: ['*-webpack-loader', '*-web-loader', '*-loader', '*'],
|
2016-12-07 19:25:31 +01:00
|
|
|
extensions: ['', '.js']
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
2017-02-01 18:25:59 +01:00
|
|
|
|
|
|
|
/** Pass variables into modules */
|
2016-12-07 19:25:31 +01:00
|
|
|
new webpack.DefinePlugin({
|
2017-01-10 19:22:40 +01:00
|
|
|
NODE_ENV: JSON.stringify(NODE_ENV),
|
|
|
|
VERSION: JSON.stringify(VERSION)
|
2017-02-01 18:25:59 +01:00
|
|
|
}),
|
|
|
|
|
|
|
|
/** Минифицируем CSS и JS */
|
2017-11-01 22:27:20 +01:00
|
|
|
// new webpack.optimize.UglifyJsPlugin({
|
2017-02-05 15:50:48 +01:00
|
|
|
/** Disable warning messages. Cant disable uglify for 3rd party libs such as html-janitor */
|
2017-11-01 22:27:20 +01:00
|
|
|
// compress: {
|
|
|
|
// warnings: false
|
|
|
|
// }
|
|
|
|
// }),
|
2017-02-01 18:25:59 +01:00
|
|
|
|
|
|
|
/** Block biuld if errors found */
|
2017-11-20 22:17:18 +01:00
|
|
|
// new webpack.NoErrorsPlugin(),
|
2017-02-01 18:25:59 +01:00
|
|
|
|
2016-12-07 19:25:31 +01:00
|
|
|
],
|
|
|
|
|
|
|
|
module : {
|
|
|
|
|
2017-11-01 22:27:20 +01:00
|
|
|
loaders : [ {
|
2016-12-07 19:25:31 +01:00
|
|
|
test : /\.js$/,
|
2017-11-01 22:27:20 +01:00
|
|
|
exclude: /node_modules/,
|
2016-12-07 19:25:31 +01:00
|
|
|
loader : 'babel',
|
|
|
|
query: {
|
2017-11-01 22:27:20 +01:00
|
|
|
presets: [ __dirname + '/node_modules/babel-preset-es2015' ]
|
2016-12-07 19:25:31 +01:00
|
|
|
}
|
|
|
|
},
|
2017-01-10 19:22:40 +01:00
|
|
|
{
|
|
|
|
test : /\.js$/,
|
2017-04-23 16:11:03 +02:00
|
|
|
loader: 'eslint-loader?fix=true',
|
2017-11-01 22:27:20 +01:00
|
|
|
exclude: /node_modules/
|
2017-01-10 19:22:40 +01:00
|
|
|
},
|
2016-12-07 19:25:31 +01:00
|
|
|
{
|
|
|
|
test : /\.css$/,
|
2017-11-01 22:27:20 +01:00
|
|
|
exclude: /node_modules/,
|
2016-12-07 19:25:31 +01:00
|
|
|
loader: ExtractTextWebpackPlugin.extract('style-loader', 'css-loader')
|
2017-11-01 22:27:20 +01:00
|
|
|
} ]
|
2016-12-07 19:25:31 +01:00
|
|
|
}
|
|
|
|
};
|