-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·84 lines (81 loc) · 1.79 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
var path = require("path");
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var cssnext = require('postcss-cssnext');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
context: __dirname,
entry: {
main: './frontend/src/index.tsx',
},
devtool: 'inline-source-map',
output: {
path: path.resolve('./frontend/static/bundles/'),
filename: "[name]-[hash].js"
},
plugins: [
new BundleTracker({filename: './webpack-stats.json'}),
new webpack.LoaderOptionsPlugin({
test: /\.scss$/,
options: {
postcss: {
plugins: [cssnext],
},
},
}),
// jQuery support
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'root.jQuery': 'jquery',
}),
new ExtractTextPlugin({
filename: "[name]-[hash].css",
}),
],
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [{
loader: "css-loader"
}, {
loader: "sass-loader"
}],
// use style-loader in development
fallback: "style-loader"
}),
},
{
test: /\.tsx?$/,
include: path.join(__dirname, 'frontend/src'),
use: 'ts-loader'
},
{
test: /\.json$/,
use: 'json-loader',
},
{
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
loader: 'file-loader',
options: {
name: '[name]-[hash].[ext]',
outputPath: 'images/',
publicPath: 'frontend/static/bundles/'
}
},
{
test: /\.css$/, exclude: /node_modules/, include: path.join(__dirname, 'frontend/src'),
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
],
},
resolve: {
extensions: ['*', '.ts', '.tsx', '.json', '.', '.js', '.jsx'], // the js extensions are necessary for webpack
},
};