-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
77 lines (65 loc) · 1.62 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
'use strict';
let path = require( 'path' );
let webpack = require( 'webpack' );
let ROOT = __dirname;
let SRC = ROOT + '/src';
let BUILD = 'build';
let ENTRY_FILE = SRC + '/index.js';
let OUTPUT_FILE = 'artflow-dist';
const INCLUDES = [
'controller', 'modules', 'shader', 'utils', 'view', 'vr'
];
let env = require( 'dotenv' ).config();
let plugins = [
new webpack.ProvidePlugin( {
'THREE': 'three',
'window.THREE': 'three'
} )
];
let loaders = [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
];
/**
* Creates the array containing the different include folders.
* This is used to avoid having gross relative import!
*/
let aliases = {};
for ( let i = 0; i < INCLUDES.length; ++i )
aliases[ INCLUDES[ i ] ] = path.resolve( SRC, INCLUDES[ i ] );
//test.push( path.resolve( ROOT, './node_modules' ) );
let exp = {
entry: ENTRY_FILE,
output: {
path: path.resolve( __dirname, BUILD + '/' ),
filename: null,
publicPath: '/' + BUILD + '/',
library: 'Artflow'
},
resolve: {
alias: aliases
},
module: {}
};
if ( !env.parsed || env.parsed.WEBPACK_CONFIG !== 'build' ) {
OUTPUT_FILE = OUTPUT_FILE + '.js';
plugins.push( new webpack.HotModuleReplacementPlugin() );
} else {
OUTPUT_FILE = OUTPUT_FILE + '.min.js';
plugins.push( new webpack.optimize.UglifyJsPlugin( { minimize: true } ) );
loaders.push( {
test: /(\.jsx|\.js)$/,
loader: 'eslint-loader',
exclude: /node_modules/
} );
}
exp.output.filename = OUTPUT_FILE;
exp.plugins = plugins;
exp.module.loaders = loaders;
module.exports = exp;