-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
128 lines (124 loc) · 3.27 KB
/
Copy pathwebpack.config.js
File metadata and controls
128 lines (124 loc) · 3.27 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
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
126
127
128
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : 'development';
const mode = NODE_ENV === 'development' ? 'dev' : 'dev';
// Create multiple instances
const extractSCSS = new ExtractTextPlugin('app.css');
const extractCSS = new ExtractTextPlugin('vendor.css');
module.exports = {
devtool: 'source-map',
entry: {
// styles: path.join(__dirname, 'src', 'client', 'assets', 'scss', 'main.scss'),
// styles: path.join(__dirname, 'node_modules', 'react-dates', 'lib', 'css', '_datepicker.css'),
main: path.join(__dirname, 'src', 'client', `index.${mode}`),
},
plugins: [
extractCSS,
extractSCSS,
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.js',
minChunks(module) {
const context = module.context;
return context && context.indexOf('node_modules') >= 0;
},
}),
new webpack.IgnorePlugin(/\.\/locale$/),
],
output: {
path: path.join(__dirname, 'public'),
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: '/',
library: '[name]',
libraryTarget: 'umd',
umdNamedDefine: true,
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
alias: {
moment$: 'moment/moment.js',
},
},
devServer: {
historyApiFallback: true,
contentBase: './public',
port: 9001,
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 300,
poll: 1000,
},
},
module: {
rules: [
// less
{
test: /\.css$/,
use: extractCSS.extract(['css-loader']),
},
{
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'less-loader' },
],
},
{
test: /\.scss$/,
use: extractSCSS.extract(['css-loader', 'sass-loader']),
},
// JS/TS
// { test: /\.jsx?$/, use: [{ loader: 'babel-loader' }] },
{ test: /\.tsx?$/, use: [{ loader: 'ts-loader' }] },
// images
{
test: /\.(jpe?g|png|gif)$/i,
use: [{
loader: 'url-loader',
options: { limit: 10240 },
}],
},
// Font
{
test: /\.svg(\?[a-z0-9=&.]+)?$/,
use: [
{
loader: 'url-loader',
options: { limit: 65000, mimetype: 'image/svg+xml' },
},
],
},
{
test: /\.woff(\?[a-z0-9=&.]+)?$/,
use: [{
loader: 'url-loader',
options: { limit: 65000, mimetype: 'application/font-woff' },
}],
},
{
test: /\.woff2(\?[a-z0-9=&.]+)?$/,
use: [{
loader: 'url-loader',
options: { limit: 65000, mimetype: 'application/font-woff2' },
}],
},
{
test: /\.[ot]tf(\?[a-z0-9=&.]+)?$/,
use: [{
loader: 'url-loader',
options: { limit: 65000, mimetype: 'application/octet-stream' },
}],
},
{
test: /\.eot(\?[a-z0-9=&.]+)?$/,
use: [{
loader: 'url-loader',
options: { limit: 65000, mimetype: 'application/vnd.ms-fontobject' },
}],
},
],
},
};