-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathwebpack.config.js
73 lines (67 loc) · 2.24 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
// Example webpack configuration with asset fingerprinting in production.
'use strict';
var path = require('path');
var url = require('url');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var PATHS = {
app: path.join(__dirname, 'app'),
angularD3: './index.js',
dist: path.join(__dirname, 'dist'),
docs: path.join(__dirname, 'docs'),
styles: path.join(__dirname, 'app/styles/index.scss'),
}
var config = {
entry: {
"angularD3": PATHS.angularD3,
"app": PATHS.app
},
resolve: { extensions: ['', '.js', '.coffee', '.css', '.scss', '.less'], },
output: {
path: PATHS.dist,
filename: "[name].js"
},
module: {
loaders: [
{ test: /\.coffee$/, loader: "coffee-loader" },
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style", "css") },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader?sourceMap!sass-loader?sourceMap") },
{ test: /\.(ttf|svg|png|gif|jpg|woff|woff2|eot|csv)$/, loader: "file" },
{ test: /\.html$/, loader: "ngtemplate!html" },
]
},
plugins: [
new ExtractTextPlugin("[name].css")
]
}
if (process.env.BUILD_ASSETS === "true") {
console.log("Building assets...")
config.entry = { "angularD3": PATHS.angularD3 }
config.devtool = 'source-map'
config.output.devtoolModuleFilenameTemplate = '[resourcePath]'
config.output.devtoolFallbackModuleFilenameTemplate = '[resourcePath]?[hash]'
config.externals ={ "angular": "angular", "d3": "d3"}
} else if (process.env.BUILD_DOCS === "true") {
config.devtool = 'source-map'
config.output.path = PATHS.docs
config.output.devtoolModuleFilenameTemplate = '[resourcePath]'
config.output.devtoolFallbackModuleFilenameTemplate = '[resourcePath]?[hash]'
config.plugins.push (
new HtmlWebpackPlugin({
template: path.join(PATHS.app, 'index.html'),
favicon: path.join(PATHS.app, 'favicon.ico'),
inject: 'body'
})
)
} else {
config.devtool = 'source-map'
config.plugins.push (
new HtmlWebpackPlugin({
template: path.join(PATHS.app, 'index.html'),
favicon: path.join(PATHS.app, 'favicon.ico'),
inject: 'body'
})
)
}
module.exports = config;