2 Star 2 Fork 2

xiexuekui/myproject

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.js 2.22 KB
一键复制 编辑 原始数据 按行查看 历史
xiexuekui 提交于 2024-02-26 16:05 . 初始提交
const path = require('path');
const webpack = require('webpack');
/*
* Webpack Plugins
*/
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ProductionPlugins = [
// production webpack plugins go here
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
})
]
const debug = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const rootAssetPath = path.join(__dirname, 'assets');
module.exports = {
// configuration
context: __dirname,
entry: {
main_js: './assets/js/main',
main_css: [
path.join(__dirname, 'node_modules', '@fortawesome', 'fontawesome-free', 'css', 'all.css'),
path.join(__dirname, 'node_modules', 'bootstrap', 'dist', 'css', 'bootstrap.css'),
path.join(__dirname, 'assets', 'css', 'style.css'),
],
},
mode: debug,
output: {
chunkFilename: "[id].js",
filename: "[name].bundle.js",
path: path.join(__dirname, "myproject", "static", "build"),
publicPath: "/static/build/"
},
resolve: {
extensions: [".js", ".jsx", ".css"]
},
devtool: debug ? "eval-source-map" : false,
plugins: [
new MiniCssExtractPlugin({ filename: "[name].bundle.css" }),
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" })
].concat(debug ? [] : ProductionPlugins),
module: {
rules: [
{
test: /\.less$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
},
},
'css-loader!less-loader',
],
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
},
},
'css-loader',
],
},
{ test: /\.html$/, type: 'asset/source' },
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, type: 'asset/resource', mimetype: 'application/font-woff' },
{
test: /\.(ttf|eot|svg|png|jpe?g|gif|ico)(\?.*)?$/i,
type: 'asset/resource',
generator: {
filename: '[name][ext]'
}
},
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', options: { presets: ["@babel/preset-env"], cacheDirectory: true } },
],
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/testbigmodel666/myproject.git
[email protected]:testbigmodel666/myproject.git
testbigmodel666
myproject
myproject
master

搜索帮助