-
Notifications
You must be signed in to change notification settings - Fork 42
/
webpack.config.js
91 lines (75 loc) · 2.05 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
const path = require('path');
const webpack = require('webpack');
const HtmlwebpackPlugin = require('html-webpack-plugin');
const ENV = process.env.NODE_ENV || 'development';
const isProduction = ENV === 'production';
console.log('BUILDING WEBPACK FOR ENV', ENV, isProduction);
const config = {
context: __dirname, // string (absolute path!)
entry: {
index: path.join(__dirname, 'examples/index.js')
},
output: {
filename: '[name].js',
path: path.join(__dirname, '/dist/'),
publicPath: '/',
chunkFilename: '[id].chunk.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.styl$/,
use: [ 'style-loader', 'css-loader', 'stylus-loader' ]
},
{
test: /\.(js|jsx)$/,
exclude: [
/node_modules/
],
loader: 'babel-loader'
}
]
},
target: 'web', // enum
stats: 'errors-only',
devServer: {
port: 3030,
contentBase: path.join(__dirname, 'public'), // boolean | string | array, static file location
compress: true, // enable gzip compression
historyApiFallback: true, // true for index.html upon 404, object for multiple paths
// hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin
https: false, // true for self-signed, object for cert authority
noInfo: true, // only errors & warns on hot reload
},
plugins: [],
// Don't follow/bundle these modules, but request them at runtime from the environment
externals: [],
devtool: 'source-map'
}
if (isProduction) {
config.entry = {
index: path.join(__dirname, 'lib/index.js')
};
config.externals = {
'react': 'react',
'react-dom': 'react-dom'
};
config.output = {
filename: 'FullpageReact.js',
path: __dirname,
publicPath: '/',
library: 'FullpageReact',
libraryTarget: 'umd',
umdNamedDefine: true
};
} else {
config.plugins.push(new HtmlwebpackPlugin({
title: 'Fullpage React'
}));
}
console.log('config', config);
module.exports = config;