2020-05-15 14:16:13 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
|
|
|
|
module.exports.styleLoader = styleLoader => ({
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
{ loader: styleLoader },
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
importLoaders: 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2020-05-19 17:31:04 +00:00
|
|
|
module.exports.commonLoaders = ({ legacy = false, file = true } = {}) => {
|
2020-05-15 14:16:13 +00:00
|
|
|
const babelLoader = {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
cacheDirectory: true,
|
|
|
|
rootMode: 'upward',
|
|
|
|
presets: [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
targets: !legacy
|
|
|
|
? {
|
|
|
|
esmodules: true
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
esmodules: false,
|
|
|
|
browsers: ['ie 11']
|
|
|
|
},
|
|
|
|
useBuiltIns: 'entry',
|
|
|
|
corejs: '3'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
test: /\.(js|ts|tsx)$/,
|
|
|
|
use: babelLoader,
|
|
|
|
exclude: /node_modules|dist/
|
|
|
|
},
|
2020-05-19 17:31:04 +00:00
|
|
|
...(file
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
test: /\.(jpe?g|png|svg)$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
limit: 8192,
|
|
|
|
name: 'images/[name].[ext]'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
: []),
|
2020-05-15 14:16:13 +00:00
|
|
|
{
|
|
|
|
test: /\.yaml$/,
|
|
|
|
use: ['json-loader', 'yaml-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.toml$/,
|
|
|
|
use: ['toml-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ne$/,
|
|
|
|
use: [babelLoader, 'nearley-loader']
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.md$/,
|
|
|
|
use: ['raw-loader']
|
|
|
|
},
|
|
|
|
{
|
2020-06-23 09:43:46 +00:00
|
|
|
test: /\.(ttf|pdf)$/,
|
2020-05-15 14:16:13 +00:00
|
|
|
use: ['file-loader']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|