-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.ts
100 lines (94 loc) · 2.69 KB
/
webpack.config.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
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
97
98
99
100
import * as webpack from 'webpack'
import * as path from 'path'
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
import { LoaderOptions } from '../src/lp-loader'
export const makeConfig = (isProduction = false) => {
const isDevelopment = !isProduction
process.env.LP_DEBUG = 'true'
const appEntry = [
path.join(__dirname, '../app/app')
]
const buildDir = path.join(__dirname, 'build')
const tsLoaderOptions = {
compilerOptions: {
module: "esnext",
declaration: false,
moduleResolution: 'node',
noEmit: false
},
configFile: path.join(__dirname, 'tsconfig.json'),
}
const lpTsIndexFiles = /dict(\\|\/)index\.ts/
const lpLoader = path.join(__dirname, '../src/lp-loader')
const config: webpack.Configuration = {
mode: isDevelopment ? 'development' : 'production',
entry: {
app: appEntry
},
output: {
path: buildDir,
filename: '[name]-[hash].js',
chunkFilename: '[name]-[chunkhash].js',
publicPath: '/'
},
plugins: [
//new (webpack as any).NamedModulesPlugin(),
...isDevelopment ? [
new webpack.HotModuleReplacementPlugin()
] : [
new CleanWebpackPlugin([buildDir], {
root: path.resolve(__dirname, '../..')
})
],
new HtmlWebpackPlugin({
title: 'LP-Loader ' + (isDevelopment ? 'Dev' : 'Build'),
filename: 'index.html'
})
],
module: {
rules: [
{
test: lpTsIndexFiles, loaders: [
{
loader: lpLoader, query: {
name: 'language.pack',
include: /(\\|\/)\w{2}\.ts/
} as LoaderOptions
},
//{ loader: 'ts-loader', query: tsLoaderOptions } as any
//{ loader: path.join(__dirname, 'ts-simple-loader'), query: tsLoaderOptions } as any
]
},
{
test: /\.ts$/,
loader: 'ts-loader',
//iexclude: [lpTsIndexFiles],
query: tsLoaderOptions
},
{ test: /\.css$/, loader: 'style!css' },
]
},
devtool: isDevelopment ? 'eval' : 'inline-source-map',
resolve: {
extensions: ['.ts', '.js'],
alias: {
//'lp': path.resolve(__dirname, '../../lib/lp-loader.ts'),
}
},
resolveLoader: {
extensions: ['.ts', '.js'],
alias: {
//'ts': 'awesome-typescript-loader'
//'ts': 'ts-loader'
},
modules: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, '../node_modules'),
path.resolve(__dirname, '../src'),
]
}
}
return config
}
export default makeConfig()