-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
94 lines (93 loc) · 3.06 KB
/
webpack.config.js
File metadata and controls
94 lines (93 loc) · 3.06 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
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
var path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const SpritesmithPlugin = require('webpack-spritesmith');
module.exports = {
/* if entry is not set, default is ./src/index.js */
entry: {
main: path.resolve(__dirname, 'src/index.ts'),
// entry2: path.resolve(__dirname, 'src/entry2.js'),
},
output: {
filename: '[name].js?v=[hash]'
},
resolve: {
extensions: ['.js', '.ts'],
modules: [
path.resolve(__dirname, 'src/'),
path.resolve(__dirname, 'node_modules/'),
]
},
module: {
rules: [
{
test: /\.js$/,
loader: require.resolve('babel-loader'),
options: {
presets: ['@babel/env'],
plugins: [
'@babel/proposal-object-rest-spread',
'@babel/proposal-class-properties']
}
},
{ enforce: "pre", test: /\.js$/, loader: require.resolve('source-map-loader') },
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{
test: /\.scss$/,
use: [
process.env.NODE_ENV !== 'production' ? require.resolve('style-loader') : MiniCssExtractPlugin.loader,
require.resolve('css-loader'), // translates CSS into CommonJS
require.resolve('sass-loader') // compiles Sass to CSS, using Node Sass by default
]
}, {
test: /\.pug$/,
loader: require.resolve('pug-loader')
}, {
test: /\.(png|gif)$/,
loader: require.resolve('file-loader'),
options: {
name: 'images/[name].[ext]'
}
}
]
},
devServer: {
compress: true,
port: 8686,
proxy: {
'/api': {
// target: 'https://api-dev.langlive.com',
target: 'https://api.s.lang.live',
pathRewrite: {'^/api' : ''},
secure: false,
changeOrigin: true
},
}
},
plugins: [
new HtmlWebPackPlugin({
template: path.resolve(__dirname, 'src/index.html'),
filename: './index.html'
}),
new MiniCssExtractPlugin({
filename: '[name].css?v=[hash]',
chunkFilename: '[id].css'
}),
new SpritesmithPlugin({
src: {
cwd: path.resolve(__dirname, 'src/images/sprites'),
glob: '*.png'
},
target: {
image: path.resolve(__dirname, 'src/sprite/sprite.png'),
css: path.resolve(__dirname, 'src/scss/sprite.scss')
},
apiOptions: {
cssImageRef: "../sprite/sprite.png"
},
spritesmithOptions: {
padding: 15
}
})
]
};