-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
112 lines (110 loc) · 3.06 KB
/
webpack.common.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
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');
var APP_DIR = path.resolve(__dirname, './src');
var BUILD_DIR = path.resolve(__dirname, './dist');
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
module.exports = {
entry: {
main: [
"babel-polyfill", APP_DIR + '/index.jsx'
]
},
devtool: 'inline-source-map',
output: {
path: BUILD_DIR,
filename: '[name].app.js',
chunkFilename: '[name].bundle.js'
},
module: {
rules: [
{
test: /\.(sass|scss)$/,
include: APP_DIR,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: "css-loader",
options: {
modules: true,
importLoaders: 3,
localIdentName: '[local]___[hash:base64:5]',
// sourceMap: true,
minimize: true
}
}, {
loader: "postcss-loader",
options: {
// sourceMap: true
}
}, {
loader: "sass-loader",
options: {
// sourceMap: true
}
}, {
/*you don't need to import mixins inside each sass file
* if there will be more then 1 path, create array of strings, resources:['path1','path2']*/
loader: 'sass-resources-loader',
options: {
resources: APP_DIR + '/style/mixin.scss',
sourceMap: true
}
}
]
})
}, {
test: /\.bundle\.js$/,
loader: 'bundle-loader',
options: {
name: 'my-chunk'
}
}, {
test: /\worker\.js$/,
include: APP_DIR,
use: {
loader: 'worker-loader',
options: {
name: '[id].worker'
}
}
}, {
test: /\.(js|jsx)$/,
include: APP_DIR,
use: {
loader: 'babel-loader',
options: {
presets: [
'env', 'react'
],
plugins: ["syntax-dynamic-import", "lodash"]
}
}
}, {
test: /\.ts$/,
use: 'ts-loader',
include:APP_DIR,
exclude: /node_modules/
}, {
test: /\.(jpg|png|svg)$/,
include: APP_DIR,
loader: 'file-loader'
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
include: APP_DIR,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
include: APP_DIR,
loader: 'file-loader'
}
]
},
resolve:{
extensions: [ '.tsx', '.ts', '.js' ]
},
/*Lodash plugin does not work korectly, bug with _.filter, new LodashModuleReplacementPlugin()
*github issue=> https://github.com/gajus/react-css-modules/issues/131*/
plugins: [new ExtractTextPlugin({filename: "style.css", allChunks: true})]
}