This repository has been archived by the owner on Aug 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 253
/
webpack.common.js
96 lines (95 loc) · 3.01 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
'use strict'
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const WebpackAutoInjectVersion = require('webpack-auto-inject-version')
module.exports = {
entry: {
javascript: './src/app/App.jsx'
},
output: {
path: path.join(__dirname, '/dist/'),
filename: 'scripts/bundle.js',
publicPath: ''
},
externals: {
config: 'config'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
enforce: 'pre',
exclude: [ /node_modules/, /src\/\_app/ ],
use: [
{ loader: 'eslint-loader' }
]
},
{
test: /\.(js|jsx)$/,
exclude: [ /node_modules/ ],
use: [
{ loader: 'babel-loader', options: { babelrc: true } }
]
},
{
test: /\.html$/,
exclude: [
path.resolve(__dirname, 'src/index.html'),
],
use: [
{ loader: "html-loader" }
]
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" }, // creates style nodes from JS strings
{ loader: "css-loader" }, // translates CSS into CommonJS
]
},
{
test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'url-loader?name=fonts/[name].[ext]&limit=10000',
},
{
test: /\.(png)(\?[\s\S]+)?$/,
use: 'file-loader?name=images/[name].[ext]',
},
{
test: /\.(ttf|eot|svg|otf)(\?[\s\S]+)?$/,
use: 'file-loader?name=fonts/[name].[ext]',
},
{
test: /\.scss$/,
use: [
{ loader: "style-loader" }, // creates style nodes from JS strings
{ loader: "css-loader" }, // translates CSS into CommonJS
{ loader: "sass-loader" } // compiles Sass to CSS
]
}
]
},
plugins: [
// needs to go first to insert the file in js
new WebpackAutoInjectVersion({
components: {
AutoIncreaseVersion: false,
InjectAsComment: false,
InjectByTag: true
}
}),
// the html, which will have the bundle.js script tag injected
new HtmlWebpackPlugin({
template: 'src/app/index.html',
inject: 'body'
}),
// copy static assets
new CopyWebpackPlugin([
{ from: 'src/config.js', to: 'config.js' },
{ from: 'src/favicon.ico', to: 'favicon.ico' },
{ from: 'src/assets/images/vector_owl.png', to: 'assets/images/vector_owl.png' }
])
]
}