-
Notifications
You must be signed in to change notification settings - Fork 36
/
webpack.config.js
62 lines (60 loc) · 2.17 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
const path = require('path'),
webpack = require('webpack'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require("extract-text-webpack-plugin");
console.log("ENV:"+process.env.NODE_ENV)
var ENV = process.env.NODE_ENV,
isProd = (ENV != "development") ? true : false,
BUILD_DIR = path.resolve(__dirname, 'dist'),
APP_DIR = path.resolve(__dirname, './'),
ROOT_DIR = path.resolve(__dirname),
NODE_MODULES = path.resolve(__dirname, 'node_modules'),
config = {
entry: (isProd ? APP_DIR + "/libs/js/Editable.jsx" : APP_DIR + "/examples/index.jsx"),
output: {
path: (isProd ? BUILD_DIR : ROOT_DIR), //<- This path is use at build time
filename: "editable.js", //<- This file is created under path which we specified in output.path
library: 'Editable',
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: [
new HtmlWebpackPlugin({
title: 'Editable',
template: 'index.ejs',
filename: ROOT_DIR + '/index.html'
}), new ExtractTextPlugin({
// Extracting all css in one file, and file name is based on what you specified in filename
filename: "editable.css",
allChunks: true
}), new webpack.ProvidePlugin({
"React": "react",
}),
],
resolve: {
modules: [
APP_DIR,
NODE_MODULES
],
extensions: ['.js', '.jsx', '.json', '.css']
},
module: {
loaders: [{
test: /\.jsx$/,
exclude: [/node_modules/],
loader: "babel-loader",
include: [APP_DIR],
}, {
test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
loader: 'url-loader'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract("css-loader")
}]
}
}
if (!isProd) {
config['devtool'] = 'inline-source-map';
config['cache'] = true;
}
module.exports = config;