-
Notifications
You must be signed in to change notification settings - Fork 3
/
dev-webpack.config.js
94 lines (84 loc) · 2.95 KB
/
dev-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
85
86
87
88
89
90
91
92
93
94
//require our dependencies
var path = require('path');
var webpack = require('webpack');
const {resolve} = require('path');
var BundleTracker = require('webpack-bundle-tracker');
// const ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const APP_DIR = resolve(__dirname, 'assets/js/client');
module.exports = env => {
return {
//the base directory (abs. path) for resolving the entry option
context: __dirname,
entry: ['babel-polyfill', APP_DIR + '/circumat.js'],
output: {
//where to store compiled bundle
path: path.resolve(__dirname + '/assets/bundles/'),
//webpack naming convention where files are stores
filename: '[name]-[contenthash].js'
},
mode: 'development',
plugins: [
//where to store meta-data about the bundle
new BundleTracker({path: __dirname, filename: './webpack-stats.json'}),
new MiniCssExtractPlugin ({
filename: 'style.css',
// disable: false,
// allChunks: true
}),
new webpack.DefinePlugin({
'WEBSOCKET_URL': '"ws://127.0.0.1:8000/circumat/"',
'AJAX_URL': '"http://127.0.0.1:8000/ajaxhandling/"'
})
],
module: {
rules: [
{
include: APP_DIR,
loader: 'babel-loader',
options: {
//what will be dealing with (react code)
"presets": [
"@babel/preset-react" ,
"@babel/preset-env" ,
],
"plugins": [
"@babel/plugin-proposal-class-properties"]
},
test: /\.js$/
},
{
test: /\.(css|sass|scss)$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
url: false,
},
},
{
loader: 'sass-loader',
},
],
},
{
test: /\.woff2?$|\.ttf$|\.svg$|\.eot$/,
use: [
{
loader: 'file-loader'
}
]
}
]
},
resolve: {
//where to look for modules
extensions: ['.js', '.jsx', '.css']
}
}
};