editor.js/webpack.config.js

98 lines
2.3 KiB
JavaScript
Raw Normal View History

/**
* Webpack configuration
*
* @author Codex Team
* @copyright Khaydarov Murod
*/
'use strict';
var pkg = require('./package.json');
var 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}
*/
var webpack = require('webpack');
var ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
2017-11-01 22:27:20 +01:00
'codex-editor': './codex'
},
output: {
2017-11-01 22:27:20 +01:00
filename: '[name].js',
library: [ 'CodexEditor' ]
},
watch: true,
watchOptions: {
2017-04-22 23:53:06 +02:00
aggregateTimeOut: 50
},
2017-11-01 22:27:20 +01:00
devtool: NODE_ENV == 'development' ? 'source-map' : null,
resolve : {
2017-11-01 22:27:20 +01:00
fallback: path.join(__dirname, 'node_modules'),
modulesDirectories : [ './modules' ],
extensions : ['', '.js', '.json']
},
resolveLoader : {
2017-11-01 22:27:20 +01:00
modulesDirectories: [ './node_modules' ],
moduleTemplates: ['*-webpack-loader', '*-web-loader', '*-loader', '*'],
extensions: ['', '.js']
},
plugins: [
/** Pass variables into modules */
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(NODE_ENV),
VERSION: JSON.stringify(VERSION)
}),
/** Минифицируем CSS и JS */
2017-11-01 22:27:20 +01:00
// new webpack.optimize.UglifyJsPlugin({
/** 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
// }
// }),
/** Block biuld if errors found */
2017-11-20 22:17:18 +01:00
// new webpack.NoErrorsPlugin(),
],
module : {
2017-11-01 22:27:20 +01:00
loaders : [ {
test : /\.js$/,
2017-11-01 22:27:20 +01:00
exclude: /node_modules/,
loader : 'babel',
query: {
2017-11-01 22:27:20 +01:00
presets: [ __dirname + '/node_modules/babel-preset-es2015' ]
}
},
{
test : /\.js$/,
loader: 'eslint-loader?fix=true',
2017-11-01 22:27:20 +01:00
exclude: /node_modules/
},
{
test : /\.css$/,
2017-11-01 22:27:20 +01:00
exclude: /node_modules/,
loader: ExtractTextWebpackPlugin.extract('style-loader', 'css-loader')
2017-11-01 22:27:20 +01:00
} ]
}
};