nacos/console-ui/build/webpack.base.conf.js

103 lines
2.5 KiB
Java
Raw Normal View History

/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2018-11-18 13:58:33 +08:00
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const isDev = process.env.NODE_ENV !== 'production';
function resolve(dir) {
return path.join(__dirname, '..', dir);
}
module.exports = {
entry: {
main: './src/index.js',
},
output: {
2018-11-22 14:29:48 +08:00
filename: './js/[name].js',
2018-11-18 13:58:33 +08:00
path: path.resolve(__dirname, '../dist'),
},
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
2018-11-18 13:58:33 +08:00
alias: {
'@': resolve('src'),
2018-11-20 14:39:46 +08:00
utils: resolve('src/utils'),
components: resolve('src/components'),
2018-11-18 13:58:33 +08:00
},
},
externals: {
jquery: 'jQuery'
},
2019-04-19 17:55:43 +08:00
node: {
fs: 'empty'
},
2018-11-18 13:58:33 +08:00
module: {
2018-11-20 14:39:46 +08:00
rules: [
{
test: /\.(css|scss)$/,
use: [isDev ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
2018-11-18 13:58:33 +08:00
},
2018-11-20 14:39:46 +08:00
{
test: /\.(js|jsx)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src')],
},
{
test: /\.(js|jsx|ts|tsx)$/,
2018-11-20 14:39:46 +08:00
include: [resolve('src')],
use: ['babel-loader'],
},
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
2018-11-18 13:58:33 +08:00
loader: 'url-loader',
options: {
2018-11-20 14:39:46 +08:00
limit: 10000,
name: '/img/[name].[hash:8].[ext]',
2018-11-18 13:58:33 +08:00
},
2018-11-20 14:39:46 +08:00
},
{
test: /\.(ttf|woff|svg)$/,
use: [
{
loader: 'url-loader',
options: {
name: '/fonts/[name].[hash:8].[ext]',
},
},
],
},
],
2018-11-18 13:58:33 +08:00
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './public/index.html',
minify: !isDev,
}),
2018-11-20 14:39:46 +08:00
new CopyWebpackPlugin([
{
from: resolve('public'),
to: './',
ignore: ['index.html'],
},
]),
2018-11-18 13:58:33 +08:00
],
};