-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.js
More file actions
65 lines (64 loc) · 2.25 KB
/
webpack.dev.js
File metadata and controls
65 lines (64 loc) · 2.25 KB
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
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path');
const srcDir = path.join(__dirname, "src")
const buildPath = path.join(__dirname, 'www')
module.exports = {
context: srcDir,
devtool: 'source-map',
entry: [
'babel-polyfill',
'./index.tsx',
],
output: {
path: buildPath,
filename: '[name].[chunkhash].js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, include: srcDir, loader: "awesome-typescript-loader" },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ test: /\.js$/, include: srcDir, loader: ['babel-loader', 'source-map-loader'], enforce: 'pre' },
{
test: /\.css$/, // for application CSS
include: [srcDir],
loader: [
'style-loader',
'typings-for-css-modules-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]&namedExport&camelCase',
]
},
{
test: /\.css$/, // for node_modules CSS
exclude: [srcDir],
loader: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]&namedExport&camelCase',
]
},
{ test: /\.woff(\?.+)?$/, use: 'url-loader?limit=10000&mimetype=application/font-woff' },
{ test: /\.woff2(\?.+)?$/, use: 'url-loader?limit=10000&mimetype=application/font-woff' },
{ test: /\.ttf(\?.+)?$/, use: 'file-loader' },
{ test: /\.eot(\?.+)?$/, use: 'file-loader' },
{ test: /\.svg(\?.+)?$/, use: 'file-loader' },
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'index.ejs'),
path: buildPath,
// excludeChunks: ['base'],
filename: 'index.html',
minify: {
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeComments: true,
removeRedundantAttributes: true
}
}),
new webpack.WatchIgnorePlugin([/css\.d\.ts$/]) // To avoid build loop for generated css.d.ts files by typings-for-css-modules-loader
]
};