-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
93 lines (88 loc) · 2.4 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
/*
* @Author: lich
* @Date: 2019-10-24 17:56:09
* @Last Modified by: lich
* @Last Modified time: 2020-03-17 10:47:20
* @TODO:采用cdn加速
*/
// / <reference types="./nodejs.d.ts" />
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
/** @type { import("webpack").Configuration } */
const webpackConfig = {
// mode: 'development',
entry: path.join(__dirname, 'src', 'index'),
// watch: true,
output: {
path: path.resolve(__dirname, 'dist'),
// publicPath: '/dist/',
filename: 'aol.js',
chunkFilename: '[name].js',
},
devtool: 'source-map',
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: 'awesome-typescript-loader' },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: 'pre',
test: /.jsx?$/,
include: [path.resolve(__dirname, 'src')],
// exclude: [
// path.resolve(__dirname, 'node_modules')
// ],
loader: 'source-map-loader',
},
{
test: /\.s[ac]ss$/i,
// exclude: [path.resolve(__dirname, 'node_modules')],
include: [path.resolve(__dirname, 'src')],
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
// name(file) {
// if (env === 'development') {
// return '[path][name].[ext]';
// }
// return '[hash].[ext]';
// },
},
},
],
include: [path.resolve(__dirname, 'src')],
},
],
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx'],
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
// https://webpack.docschina.org/concepts/mode/#mode-production
// optimization: {
// minimize: false,
// },
target: 'web',
plugins: [new HtmlWebpackPlugin({ template: './public/index.html' })],
externals: [
// 引入包的默认 entry
{
angular: 'angular',
},
],
};
module.exports = webpackConfig;