-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
57 lines (53 loc) · 1.73 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
'use strict';
var path = require('path');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
cache: true,
entry: ['./src/App.tsx', './scss/style.scss'],
// Where the output of our compilation ends up
output: {
path: path.resolve(__dirname, './dist/'),
filename: '[name].js',
chunkFilename: '[chunkhash].js'
},
module: {
loaders: [{
// The loader that handles ts and tsx files. These are compiled
// with the ts-loader and the output is then passed through to the
// babel-loader. The babel-loader uses the es2015 and react presets
// in order that jsx and es6 are processed.
test: /\.ts(x?)$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015&presets[]=react!ts-loader'
}, {
// The loader that handles any js files presented alone.
// It passes these to the babel-loader which (again) uses the es2015
// and react presets.
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}, {
test: /\.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
}]
},
plugins: [
new MiniCssExtractPlugin({
publicPath: '/dist/css',
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "dist/css/style.css"
})
],
resolve: {
// Files with the following extensions are fair game for webpack to process
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js', '*.scss', '*.css']
},
};