forked from tacowordpress/addmany
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
94 lines (83 loc) · 2.25 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
94
'use strict';
let WebpackNotifierPlugin = require('webpack-notifier');
let ExtractTextPlugin = require('extract-text-webpack-plugin');
let webpack = require('webpack');
let fs = require('fs');
let path = require('path');
let base_path = './';
let is_production = false;
let node_dir = __dirname + '/node_modules/';
let source_path = './src/js/';
let output_path = './';
// Get all top level files
let files = fs.readdirSync(source_path);
let entry_points = {};
files.forEach(function(file) {
if(file[0] === '.') {
return;
}
let stat = fs.statSync(source_path + file);
if (stat.isFile()) {
let base_name = path.basename(file, path.extname(file));
entry_points[base_name] = source_path + file;
}
});
process.argv.forEach(function(arg) {
if (arg === '-p' || arg === '--production') {
is_production = true;
}
});
let config = {
add_vendor: function (name, path) {
this.resolve.alias[name] = path;
this.module.noParse.push(new RegExp(path));
this.entry[name] = [name];
},
entry: {
'addmany': base_path + '/src/js/addmany.js',
},
output: {
path: output_path + 'dist/',
filename: '[name]' + (is_production === true ? '.min' : '') + '.js'
},
resolve: { alias: {} },
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/,
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?sourceMap!sass-loader?sourceMap=map')
},
{
test: /\.(jpg|png|svg|gif|eot|ttf|woff|woff2)(\?.+)?$/,
loader: 'file-loader?name=assets/[name].[ext]'
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react'],
},
}
],
noParse: []
},
plugins: [
new ExtractTextPlugin('[name]' + (is_production === true ? '.min' : '') + '.css'),
new WebpackNotifierPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': (is_production === true ? '"production"' : '"development"')
}
})
]
};
module.exports = config;