webpack.config.js
1.57 KB
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
/* global __dirname */
var argv = require("yargs").argv;
var path = require("path");
var glob = require("glob");
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var extension = ".js";
if (argv.production) {
extension = ".min.js"
}
var testFiles = glob.sync("./src/**/*.[sS]pec.ts");
var uglifyLoaderConfig = {
// I want to uglify with mangling only app files, not thirdparty libs
test: /\.js$/,
exclude: /.spec.js/, // excluding .spec files
loader: "uglify"
};
var testingFiles = glob.sync("./src/app/**/*.[sS]pec.ts");
var webpackConfig = {
entry: {
noosfero: './src/app/index.ts',
'noosfero-specs': './src/specs.ts'
},
plugins: [ new CommonsChunkPlugin("commons.js")],
output: {
path: path.join(__dirname, "src"),
filename: "[name]" + extension,
},
/*plugins: [ new webpack.optimize.CommonsChunkPlugin("common.js") ],*/
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
// Source maps support (or 'inline-source-map' also works)
devtool: 'inline-source-map',
module: {
loaders: [{
test: /\.css$/,
loader: "style!css"
}, {
test: /\.scss$/,
loaders: ["style", "css?sourceMap", "sass?sourceMap"]
}, {
test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/,
loader: 'url-loader?limit=100000'
}, {
test: /\.tsx?$/,
loader: 'ts-loader'
}]
}
};
if (argv.production) {
webpackConfig.module.loaders.push(uglifyLoaderConfig);
}
module.exports = webpackConfig;