nwscreen-ui/build/webpack.base.conf.js

104 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

2024-08-13 12:08:32 +08:00
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
2024-09-13 17:58:49 +08:00
function resolve(dir) {
2024-08-13 12:08:32 +08:00
return path.join(__dirname, '..', dir)
}
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
2024-09-13 17:58:49 +08:00
app: './src/main.js',
2024-08-13 12:08:32 +08:00
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
2024-09-13 17:58:49 +08:00
publicPath:
process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath,
2024-08-13 12:08:32 +08:00
},
resolve: {
2024-09-13 17:58:49 +08:00
extensions: ['.js', '.vue', '.json', '.css', '.png'],
2024-08-13 12:08:32 +08:00
alias: {
2024-09-13 17:58:49 +08:00
vue$: 'vue/dist/vue.esm.js',
2024-08-13 12:08:32 +08:00
'@': resolve('src'),
2024-09-13 17:58:49 +08:00
},
2024-08-13 12:08:32 +08:00
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
2024-09-13 17:58:49 +08:00
options: vueLoaderConfig,
2024-08-13 12:08:32 +08:00
},
{
test: /\.js$/,
loader: 'babel-loader',
2024-09-13 17:58:49 +08:00
include: [
resolve('src'),
resolve('test'),
resolve('node_modules/webpack-dev-server/client'),
],
},
2024-08-13 12:08:32 +08:00
{
test: /\.svg$/,
loader: 'svg-sprite-loader',
include: [resolve('src/icons')],
options: {
2024-09-13 17:58:49 +08:00
symbolId: 'icon-[name]',
},
2024-08-13 12:08:32 +08:00
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
2024-09-13 17:58:49 +08:00
exclude: [resolve('src/icons')],
2024-08-13 12:08:32 +08:00
options: {
// limit: 10000,
// name: utils.assetsPath('img/[name].[hash:7].[ext]')
2024-09-13 17:58:49 +08:00
},
2024-08-13 12:08:32 +08:00
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
2024-09-13 17:58:49 +08:00
name: utils.assetsPath('media/[name].[hash:7].[ext]'),
},
2024-08-13 12:08:32 +08:00
},
{
// 加载图标
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
2024-09-13 17:58:49 +08:00
name: utils.assetsPath('fonts/[name].[hash:7].[ext]'),
},
2024-08-13 12:08:32 +08:00
},
// {
// test: /\.less$/,
// loader: "style-loader!css-loader!less-loader"
// },
{
2024-09-13 17:58:49 +08:00
test: / .scss$ /,
loaders: ['style', 'css', 'sass'],
2024-08-13 12:08:32 +08:00
},
2024-09-13 17:58:49 +08:00
],
2024-08-13 12:08:32 +08:00
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
2024-09-13 17:58:49 +08:00
child_process: 'empty',
},
2024-08-13 12:08:32 +08:00
}