-
Notifications
You must be signed in to change notification settings - Fork 73
/
webpack.dev.ts
57 lines (49 loc) · 2 KB
/
webpack.dev.ts
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
/***********************************************************
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License
**********************************************************/
import { Configuration as WebpackConfig, NormalModuleReplacementPlugin } from 'webpack';
import { Configuration as WebpackDevServerConfig } from "webpack-dev-server";
import { merge } from 'webpack-merge';
import common from './webpack.common';
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // tslint:disable-line: no-var-requires
interface Config extends WebpackConfig {
devServer?: WebpackDevServerConfig
}
const config: Config = merge(common, {
mode: 'development',
// Enable sourcemaps for debugging webpack's output.
devtool: 'source-map',
module: {
rules: [
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader', exclude: /node_modules/ },
{
test: /\.(scss|css)$/,
use: [
{ loader: 'style-loader'},
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { sourceMap: true}},
{ loader: 'sass-loader', options: {sourceMap: true, implementation: require('sass')}}]
}
]
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// all options are optional
chunkFilename: '[id].css',
filename: '[name].css',
ignoreOrder: false, // Enable to remove warnings about conflicting order
}),
new NormalModuleReplacementPlugin(
/(.*)appConfig.ENV(\.*)/,
resource => resource.request = resource.request.replace(/ENV/, 'dev')
)
],
devServer: {
compress: true,
historyApiFallback: true,
}
});
export default config;