-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
94 lines (88 loc) · 3.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
92
93
94
/**
* Usage:
* API_KEY=xxx webpack -p | -d
*/
var webpack = require('webpack'),
path = require('path'),
ExtractTextPlugin = require("extract-text-webpack-plugin"),
CopyWebpackPlugin = require('copy-webpack-plugin');
var contextDir = path.join(__dirname, 'src'),
API_KEY = process.env.API_KEY, // pass API_KEY from environment or command line
outputDir = process.argv.find(function(o) { return o.startsWith('-p') }) ? 'dist.min' : 'dist';
console.log('output dir:', outputDir);
if (!API_KEY) {
// API_KEY not found in environment
console.log('reading API_KEY from trello-api-key.json');
// trello-api-key.json shall contain just the key enclosed in double quotes
API_KEY = require('./trello-api-key.json');
}
console.log('API key:', API_KEY);
module.exports = {
context: contextDir,
entry: {
vendor: 'vendor.ts',
app: 'app.bootstrap.ts'
},
output: {
path: outputDir,
filename: '[name].bundle.js',
sourceMapFilename: '[file].map',
chunkFilename: '[id].chunk.js'
},
resolve: {
root: [contextDir],
extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
},
module: {
loaders: [
{test: /\.ts$/, loaders: ['awesome-typescript', 'angular2-template']},
{test: /\.css$/, loader: ExtractTextPlugin.extract([/*'style',*/ 'css?-autoprefixer&minimize&importLoaders=1&sourceMap', 'postcss'])},
{test: /\.scss$/, loader: ExtractTextPlugin.extract([/*'style',*/ 'css?-autoprefixer&minimize&importLoaders=1&sourceMap', 'postcss', 'sass?sourceMap'])},
{test: /\.(woff|woff2|eot|ttf|svg)$/, loader: 'file?name=assets/[name].[ext]'},
{test: /\.html?$/, loader: 'raw'}
]
},
plugins: [
// new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}}),
new webpack.DefinePlugin({
TRELLO_API_KEY: JSON.stringify(API_KEY)
}),
new webpack.ProvidePlugin({ // for Bootstrap to work
jQuery: 'jquery'
}),
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.CommonsChunkPlugin({name: ['app', 'vendor'], minChunks: Infinity}),
new ExtractTextPlugin('[name].css', {allChunks: true}),
new CopyWebpackPlugin([
{from: 'index.html'}
]),
function() {
// print timestamp every time when build is triggered
this.plugin('watch-run', function(watching, callback) {
console.log('Begin compile at ' + new Date().toTimeString());
callback();
})
}
],
sassLoader: {
outputStyle: 'nested',
precision: 10,
errLogToConsole: true
},
postcss: function() {
return [
require('autoprefixer')({browsers: ['last 3 versions']})
];
},
cache: true,
// debug: true,
// devtool: 'source-map',
node: {
global: 1,
crypto: 'empty',
module: 0,
Buffer: 0,
clearImmediate: 0,
setImmediate: 0
}
};