This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
/
webpack.config.js
112 lines (109 loc) · 2.89 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
// By default eslint assumes packages imported are supposed to be dependencies,
// not devDependencies. Disabling this rule in webpack.conig.js
/* eslint-disable import/no-extraneous-dependencies */
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const I18nAggregatorPlugin = require('terra-i18n-plugin');
const i18nSupportedLocales = require('terra-i18n/lib/i18nSupportedLocales');
module.exports = {
entry: {
'babel-polyfill': 'babel-polyfill',
'terra-core': path.resolve(path.join(__dirname, 'src', 'Index')),
},
module: {
loaders: [{
test: /\.(jsx|js)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.(scss|css)$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 2,
localIdentName: '[name]__[local]___[hash:base64:5]',
},
}, {
loader: 'postcss-loader',
},
{
loader: 'sass-loader',
options: {
data: '$bundled-themes: mock, consumer;',
},
}],
}),
},
{
test: /\.md$/,
loader: 'raw-loader',
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader',
],
},
],
},
plugins: [
new ExtractTextPlugin('[name]-[hash].css'),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'index.html'),
chunks: ['babel-polyfill', 'terra-core'],
}),
new I18nAggregatorPlugin({
baseDirectory: __dirname,
supportedLocales: i18nSupportedLocales,
}),
new webpack.NamedChunksPlugin(),
],
resolve: {
extensions: ['.js', '.jsx'],
modules: [path.resolve(__dirname, 'aggregated-translations'), 'node_modules'],
// See https://github.com/facebook/react/issues/8026
alias: {
react: path.resolve(__dirname, 'node_modules', 'react'),
'react-intl': path.resolve(__dirname, 'node_modules/react-intl'),
moment: path.resolve(__dirname, 'node_modules/moment'),
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
},
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'dist'),
},
devtool: 'cheap-source-map',
devServer: {
host: '0.0.0.0',
disableHostCheck: true,
stats: {
assets: true,
children: false,
chunks: false,
hash: false,
modules: false,
publicPath: false,
timings: true,
version: true,
warnings: true,
},
overlay: {
warnings: true,
errors: true,
},
},
resolveLoader: {
modules: [path.resolve(path.join(__dirname, 'node_modules'))],
},
};