2016-09-15 21:53:29 +00:00
|
|
|
var webpack = require('webpack');
|
|
|
|
var path = require('path');
|
|
|
|
var ExtractTextPlugin = require("extract-text-webpack-plugin");
|
2016-09-16 21:04:43 +00:00
|
|
|
var HtmlWebpackPlugin = require("html-webpack-plugin");
|
2016-09-30 20:16:24 +00:00
|
|
|
var package = require('../package.json');
|
|
|
|
var dependencies = package.dependencies;
|
2016-09-15 21:53:29 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2016-09-23 23:24:52 +00:00
|
|
|
devtool: 'source-map',
|
2016-09-15 21:53:29 +00:00
|
|
|
entry: {
|
|
|
|
app: path.resolve(__dirname, '..', 'src', 'index.js'),
|
2016-09-30 20:16:24 +00:00
|
|
|
vendor: Object.keys(dependencies),
|
2016-09-15 21:53:29 +00:00
|
|
|
},
|
|
|
|
output: {
|
2016-09-19 21:16:33 +00:00
|
|
|
publicPath: '/',
|
2016-09-16 18:11:29 +00:00
|
|
|
path: path.resolve(__dirname, '../build'),
|
2016-09-30 21:23:15 +00:00
|
|
|
filename: '[name].[chunkhash].dev.js',
|
2016-09-15 21:53:29 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
src: path.resolve(__dirname, '..', 'src'),
|
|
|
|
shared: path.resolve(__dirname, '..', 'src', 'shared'),
|
|
|
|
style: path.resolve(__dirname, '..', 'src', 'style'),
|
|
|
|
utils: path.resolve(__dirname, '..', 'src', 'utils'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
preLoaders: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
loader: 'json',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
2016-09-27 18:07:17 +00:00
|
|
|
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader!resolve-url!sass?sourceMap'),
|
2016-09-15 21:53:29 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader'),
|
|
|
|
},
|
|
|
|
{
|
2017-04-04 19:22:47 +00:00
|
|
|
test : /\.(ico|png|cur|jpg|ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
|
2016-09-27 18:07:17 +00:00
|
|
|
loader : 'file',
|
2016-09-15 21:53:29 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'babel',
|
|
|
|
query: {
|
2017-01-12 21:59:07 +00:00
|
|
|
presets: ['es2015', 'react', 'stage-0'],
|
2016-09-15 21:53:29 +00:00
|
|
|
cacheDirectory: true, // use a cache directory to speed up compilation
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2016-10-26 20:29:25 +00:00
|
|
|
sassLoader: {
|
|
|
|
includePaths: [path.resolve(__dirname, "node_modules")],
|
|
|
|
},
|
2016-09-15 21:53:29 +00:00
|
|
|
eslint: {
|
|
|
|
failOnWarning: false,
|
|
|
|
failOnError: false,
|
|
|
|
},
|
|
|
|
plugins: [
|
2016-09-30 20:16:24 +00:00
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
$: "jquery",
|
|
|
|
jQuery: "jquery",
|
|
|
|
}),
|
2017-01-12 18:57:40 +00:00
|
|
|
new ExtractTextPlugin("chronograf.css"),
|
2016-09-16 22:16:48 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, '..', 'src', 'index.template.html'),
|
|
|
|
inject: 'body',
|
2016-10-10 21:11:49 +00:00
|
|
|
favicon: 'assets/images/favicon.ico',
|
2016-09-16 22:16:48 +00:00
|
|
|
}),
|
2016-09-30 20:16:24 +00:00
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
names: ['vendor', 'manifest'],
|
|
|
|
}),
|
2017-02-15 18:57:52 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
VERSION: JSON.stringify(require('../package.json').version),
|
|
|
|
}),
|
2016-09-15 21:53:29 +00:00
|
|
|
],
|
|
|
|
postcss: require('./postcss'),
|
|
|
|
target: 'web',
|
|
|
|
};
|