2019-05-24 20:09:35 +08:00
|
|
|
const path = require('path')
|
2020-03-20 22:52:54 +08:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2020-09-17 01:02:59 +08:00
|
|
|
const { DefinePlugin } = require('webpack')
|
2019-05-24 20:09:35 +08:00
|
|
|
|
|
|
|
exports.alias = {
|
2020-03-04 19:25:46 +08:00
|
|
|
'naive-ui/lib/icons': path.resolve(__dirname, '../src/_icons'),
|
2020-09-27 01:30:48 +08:00
|
|
|
'naive-ui': path.resolve(__dirname, '../src/index.js'),
|
2020-02-12 17:34:58 +08:00
|
|
|
'src': path.resolve(__dirname, '../src')
|
2019-06-04 11:30:56 +08:00
|
|
|
}
|
2019-10-10 22:38:29 +08:00
|
|
|
|
2020-08-19 23:30:04 +08:00
|
|
|
exports.resolve = {
|
|
|
|
extensions: ['.js', '.vue', '.json', '.entry', '.demo-entry.md', '.demo.md', '.md'],
|
|
|
|
alias: exports.alias,
|
|
|
|
modules: ['node_modules']
|
|
|
|
}
|
|
|
|
|
2020-03-20 22:52:54 +08:00
|
|
|
exports.docLoaders = (env) => [
|
2019-10-10 22:38:29 +08:00
|
|
|
{
|
2020-08-19 23:30:04 +08:00
|
|
|
test: /index\.entry$/,
|
2019-10-10 22:38:29 +08:00
|
|
|
loader: ['vue-loader', path.resolve(__dirname, '../demo/loaders/NaiveUIDocEntryLoader.js')]
|
|
|
|
},
|
|
|
|
{
|
2020-08-19 23:30:04 +08:00
|
|
|
test: /\.demo\.md$/,
|
|
|
|
loader: ['vue-loader', path.resolve(__dirname, '../demo/loaders/NaiveUIDemoLoader.js')]
|
2019-10-10 22:38:29 +08:00
|
|
|
},
|
|
|
|
{
|
2020-08-19 23:30:04 +08:00
|
|
|
test: /\.demo-entry\.md$/,
|
|
|
|
loader: ['vue-loader', path.resolve(__dirname, '../demo/loaders/NaiveUIDocLoader.js')]
|
2019-10-10 22:38:29 +08:00
|
|
|
},
|
2020-08-19 23:30:04 +08:00
|
|
|
// TODO: update loader test
|
2019-10-10 22:38:29 +08:00
|
|
|
{
|
|
|
|
test: {
|
|
|
|
test: /\.md$/,
|
2020-08-19 23:30:04 +08:00
|
|
|
exclude: [/\.demo-entry\.md$/, /\.demo\.md$/]
|
2019-10-10 22:38:29 +08:00
|
|
|
},
|
2020-08-19 23:30:04 +08:00
|
|
|
loader: ['vue-loader', path.resolve(__dirname, '../demo/loaders/NaiveUIMdLoader.js')]
|
2019-10-10 22:38:29 +08:00
|
|
|
},
|
|
|
|
{
|
2020-08-19 23:30:04 +08:00
|
|
|
test: /\.vue$/,
|
2019-10-10 22:38:29 +08:00
|
|
|
loader: 'vue-loader',
|
|
|
|
options: {
|
|
|
|
compilerOptions: {
|
2020-08-27 13:36:13 +08:00
|
|
|
whitespace: 'condense'
|
2019-10-10 22:38:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(js|jsx)$/,
|
|
|
|
exclude: [/node_modules/],
|
2019-10-30 18:59:47 +08:00
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
plugins: ['@babel/plugin-syntax-dynamic-import']
|
|
|
|
}
|
2019-10-10 22:38:29 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(scss|css)$/,
|
2020-03-20 22:52:54 +08:00
|
|
|
use: [...(env === 'production' ? [MiniCssExtractPlugin.loader] : []), ...(env === 'production' ? [] : ['style-loader']), 'css-loader', 'postcss-loader', 'sass-loader']
|
2019-10-10 22:38:29 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
|
|
|
|
loader: 'url-loader',
|
|
|
|
query: {
|
|
|
|
limit: 10000,
|
|
|
|
name: path.posix.join('static', '[name].[hash:7].[ext]')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-09-17 01:02:59 +08:00
|
|
|
|
|
|
|
exports.plugins = [
|
|
|
|
new DefinePlugin({
|
|
|
|
__DEV__: JSON.stringify(process.env.NODE_ENV === 'development')
|
|
|
|
})
|
|
|
|
]
|