forked from project-sunbird/genie-sdk-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
120 lines (111 loc) · 3.31 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const path = require('path')
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var isTest = false;
var atlOptions = "";
module.exports = {
entry: 'src/index.ts',
devtool: 'source-map',
context: __dirname,
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
pathinfo: true,
libraryTarget: 'umd',
},
resolve: {
modules: ['.', 'src', 'node_modules'].map(x => path.join(__dirname, x)),
extensions: ['.ts', '.js', 'scss', 'css', 'html'],
},
plugins: [
new ExtractTextPlugin("bundle.css")
],
module: {
rules: [
// Support for .ts files.
{
test: /\.ts$/,
loaders: ['ts-loader?' + atlOptions, 'angular2-template-loader'],
exclude: [isTest ? /\.(e2e)\.ts$/ : /\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/]
},
// copy those assets to output
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader?name=fonts/[name].[hash].[ext]?'
},
// Support for *.json files.
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
// Support for CSS as raw text
// use 'null' loader in test mode (https://github.com/webpack/null-loader)
// all css in src/style will be bundled in an external css file
// {
// test: /\.css$/,
// exclude: root('src', 'app'),
// loader: isTest ? 'null-loader' : ExtractTextPlugin.extract({
// fallback: 'style-loader',
// use: ['css-loader', 'postcss-loader']
// })
// },
// all css required in src/app files will be merged in js files
// {
// test: /\.css$/,
// include: root('src', 'app'),
// loader: 'raw-loader!postcss-loader'
// },
// support for .scss files
// use 'null' loader in test mode (https://github.com/webpack/null-loader)
// all css in src/style will be bundled in an external css file
// {
// test: /\.(scss|sass)$/,
// exclude: root('src', 'app'),
// loader: isTest ? 'null-loader' : ExtractTextPlugin.extract({
// fallback: 'style-loader',
// use: ['css-loader', 'postcss-loader', 'sass-loader']
// })
// },
// all css required in src/app files will be merged in js files
// {
// test: /\.(scss|sass)$/,
// exclude: root('src', 'style'),
// loader: 'raw-loader!postcss-loader!sass-loader'
// },
// support for .html as raw text
// todo: change the loader to something that adds a hash to images
{
test: /\.html$/,
loader: 'raw-loader',
exclude: root('src', 'public')
}
]
},
externals: [
'fs',
'untildify',
/^rxjs/,
/^@angular/,
/^@ng-bootstrap/,
/^ionic-/,
/^@ionic/,
'ionicons',
/^@ionic\/.+$/,
/^ionic\/.+$/,
/^ionic-\/.+$/,
]
}
// Helper functions
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}