-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
93 lines (91 loc) · 2.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
85
86
87
88
89
90
91
92
93
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const commonPaths = {
root: path.resolve(__dirname),
outputPath: path.resolve(__dirname, 'dist'),
entryPath: path.resolve(__dirname, 'src/index.js'),
browserEntryPath: path.resolve(__dirname, 'src/index.browser.js'),
typingsFromPath: path.resolve(__dirname, 'src/index.d.ts'),
typingsToPath: path.resolve(__dirname, 'dist/index.d.ts'),
examplePath: {
html: path.resolve(__dirname, 'example/index.html'),
js: path.resolve(__dirname, 'example/index.js'),
},
chunkFilename: '[name].chunk.[chunkhash:8].js',
cssFolder: 'css',
jsFolder: 'js',
};
module.exports = {
entry: commonPaths.examplePath.js,
mode: 'development',
output: {
filename: '[name].js',
path: commonPaths.outputPath,
chunkFilename: '[name].js',
},
module: {
rules: [
{
test: /\.(css|scss)$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: true,
camelCase: true,
localIdentName: '[local]___[hash:base64:5]',
},
},
'sass-loader',
],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
fallback: 'file-loader',
name: '[name][md5:hash].[ext]',
outputPath: 'assets/',
publicPath: '/assets/'
}
}
]
},
{
enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
exclude: /(node_modules)/,
options: {
emitWarning: process.env.NODE_ENV !== 'production',
},
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules)/,
},
],
},
resolve: {
modules: ['src', 'node_modules'],
extensions: ['*', '.js', '.jsx', '.css', '.scss'],
},
plugins: [
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
template: commonPaths.examplePath.html,
filename: './index.html'
}),
],
devServer: {
port: 3001,
compress: true,
},
devtool: 'source-map',
};