forked from daostack/alchemy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.config.js
88 lines (77 loc) · 2.52 KB
/
webpack.base.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ENV = process.env.NODE_ENV || 'development';
const isProd = ENV === 'production';
const isDev = ENV === 'development';
const basePath = process.cwd();
module.exports = {
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
alias: {
actions: path.resolve(basePath, 'src/actions'),
components: path.resolve(basePath, 'src/components'),
constants: path.resolve(basePath, 'src/constants'),
layouts: path.resolve(basePath, 'src/layouts'),
lib: path.resolve(basePath, 'src/lib'),
reducers: path.resolve(basePath, 'src/reducers'),
selectors: path.resolve(basePath, 'src/selectors'),
schemas: path.resolve(basePath, 'src/schemas'),
src: path.resolve(basePath, 'src')
},
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{
test: /\.tsx?$/,
loader: ['react-hot-loader/webpack', "awesome-typescript-loader" ],
exclude: [/node_modules/, /\.spec\.ts$/]
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
},
// CSS handling
{
test: /\.css$/,
include: /client/,
use: [
'style-loader',
{ // translates CSS into CommonJS (css-loader) and automatically generates TypeScript types
loader: 'typings-for-css-modules-loader',
options: {
camelCase: true,
localIdentName: '[name]__[local]___[hash:base64:5]',
minimize: isProd,
modules: true,
namedExport: true,
sourceMap: true
}
},
],
},
// Images & fonts
{
test: /\.(png|jpg|gif|mp4|ogg|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'url-loader',
options: {
limit: 10000 // For assets smaller than 10k inline them as data urls, otherwise use regular file loader
}
},
]
},
plugins: [
// do not emit compiled assets that include errors
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new webpack.DefinePlugin({
'VERSION': JSON.stringify(require('./package.json').version)
}),
],
};