/
webpack.config.js
93 lines (87 loc) · 2.95 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//Initialization
const webpack = require('webpack');
//postcss plugins
const postcssConfig = require('./postcss');
//File ops
const HtmlwebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
// Folder ops
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
// Constants
const SRC = path.join(__dirname, 'src');
const BUILD = path.join(__dirname, 'build');
const TEMPLATE = path.join(__dirname, 'src/templates/index.html');
// const D3 = path.join(__dirname, 'src/js/public/d3.js');
// const PROTOVIS = path.join(__dirname, 'src/js/public/protovis.js');
// const PVC = path.join(__dirname, 'src/js/public/pvc.js');
const PUBLIC = path.join(__dirname, 'src/public');
module.exports = {
entry: {
index : SRC
},
output: {
path: BUILD,
// publicPath: '/',
filename: './js/[name].[hash:8].min.js'
},
resolve: {
extensions: ['', '.js', '.jsx', '.scss', '.css']
},
module: {
noParse: /node_modules\/json-schema\/lib\/validate\.js/,
loaders: [
{
test: /\.(es6|js)$/,
exclude: /(public|node_modules)/,
loaders: ['babel-loader']
},
{
test:/\.jsx?$/,
loader: 'babel',
exclude:/(node_modules)/,
query:{
presets:['react','es2015']
}
},
{test:/\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')},
// inline base64 URLs for <=8k images, direct URLs for the rest
{test: /\.(png|jpg|svg)$/, loader: "url-loader?limit=8192&name=/images/[hash:8].[name].[ext]"},
{test: /\.(ttf|woff|eot)$/, loader: "url-loader?limit=8192&name=/fonts/[hash:8].[name].[ext]"},
{
test: /\.(scss|sass)$/,
loader: 'style-loader!css-loader!autoprefixer-loader?browsers=last 2 versions!sass?sourceMap'
}
]
},
postcss() {
return postcssConfig();
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development') // eslint-disable-line quote-props
}
}),
new webpack.optimize.CommonsChunkPlugin('common','./js/common.[hash:8].min.js'),
new CopyWebpackPlugin([
{ from: PUBLIC, to: BUILD+'./js' }
],
{
ignore: [
// Doesn't copy Mac storage system files
'.DS_Store'
]
}
),
new HtmlwebpackPlugin({
title: '',
template:TEMPLATE,
filename: 'index.html',
inject:true,
hash:false
}),
new webpack.BannerPlugin('This file is created by Fine'),
new ExtractTextPlugin("./css/[hash:8].styles.css")
]
};