-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
executable file
·125 lines (117 loc) · 3.12 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
121
122
123
124
125
const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const CompressionPlugin = require("compression-webpack-plugin");
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const WebpackRTLPlugin = require('webpack-rtl-plugin');
var I18nPlugin = require("i18n-webpack-plugin");
var languages = {
"en": null,
// "de": require("./languages/de.json")
};
let config = Object.keys(languages).map(function(language) {
return {
entry: {
cc : './src/CCSDKEntry.ts',
// test : './test/ccsdk.test.ts'
},
devtool: 'inline-source-map',
devServer: {
contentBase: './dist'
},
plugins : [
new I18nPlugin(
languages[language]
),
// new webpack.ProvidePlugin({
// $: 'cash-dom'
// }),
// new UglifyJSPlugin({
// sourceMap : false
// }),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.(js)$/,
minRatio: 0.8
})
],
module: {
rules: [
// {
// test: require.resolve('cash-dom'),
// loader: 'imports-loader?this=>window'
// },
// { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" },
{
test: /\.css$/,
use: [
'style-loader',
// 'css-loader',
'rtl-css-loader'
] ,
exclude: /node_modules/
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
// fallback: "style-loader",
use: "rtl-css-loader"
})
},
// {
// test: /\.svg$/,
// loader: 'svg-inline-loader'
// },
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /\.(html)$/,
use: {
loader: 'html-loader?exportAsEs6Default',
options: {
attrs: [':data-src']
}
}
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "rtl-css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
{ test: /test\.ts$/, use: 'mocha-loader', exclude: /node_modules/ },
{ test: /\.tsx?$/, use: 'awesome-typescript-loader', exclude: /node_modules/ },
]
},
output: {
filename: '[name].' + language + '.bundle.js',
path: path.resolve(__dirname, 'dist'),
library : '[name]',
libraryTarget: 'umd',
umdNamedDefine: true
},
resolve: {
modules : [
'node_modules',
path.resolve('./src')
],
extensions: [".tsx", ".ts",'.json', '.js'],
}
}
});
config.plugins = [
new ExtractTextPlugin('css/main.scss'),
new WebpackRTLPlugin()
];
module.exports = config;