1 Star 0 Fork 1

自研插件/free-tex-packer

forked from Tonvey/free-tex-packer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.config.js 2.38 KB
一键复制 编辑 原始数据 按行查看 历史
Alexander Norinchak 提交于 2019-02-15 12:13 . Some fixes
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const argv = require('optimist').argv;
let entry = [
'babel-polyfill',
'./src/client/index'
];
let plugins = [];
let devtool = 'eval-source-map';
let output = 'static/js/index.js';
let debug = true;
let PLATFORM = argv.platform || 'web';
let NODE_ENV = argv.build ? 'production' : 'development';
let target = 'web';
if (PLATFORM === 'electron') target = 'electron-renderer';
plugins.push(new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
'PLATFORM': JSON.stringify(PLATFORM)
}));
if (argv.build) {
let outputDir;
if (PLATFORM === 'web') {
outputDir = 'web/';
}
if (PLATFORM === 'electron') {
outputDir = '../electron/www/';
}
plugins.push(new CopyWebpackPlugin([{from: 'src/client/resources', to: outputDir}]));
devtool = false;
output = outputDir + 'static/js/index.js';
debug = false;
}
else {
entry.push('webpack-dev-server/client?http://localhost:4000');
plugins.push(new CopyWebpackPlugin([{from: 'src/client/resources', to: './'}]));
}
let config = {
entry: entry,
output: {
path: __dirname + "/dist",
filename: output
},
devtool: devtool,
target: target,
mode: NODE_ENV,
module: {
noParse: /.*[\/\\]bin[\/\\].+\.js/,
rules: [
{
test: /.jsx?$/,
include: [path.resolve(__dirname, 'src')],
use: [{loader: 'babel-loader', options: {presets: ['@babel/preset-react', '@babel/preset-env']}}]
},
{
test: /\.js$/,
include: [path.resolve(__dirname, 'src')],
use: [{loader: 'babel-loader', options: {presets: ['@babel/preset-env']}}]
},
{
test: /\.(html|htm)$/,
use: [{loader: 'dom'}]
}
]
},
optimization: {
minimize: false
},
plugins: plugins
};
if (target === 'electron-renderer') {
config.resolve = {alias: {'platform': path.resolve(__dirname, './src/client/platform/electron')}};
} else {
config.resolve = {alias: {'platform': path.resolve(__dirname, './src/client/platform/web')}};
}
module.exports = config;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/self-developed-plugins/free-tex-packer.git
[email protected]:self-developed-plugins/free-tex-packer.git
self-developed-plugins
free-tex-packer
free-tex-packer
master

搜索帮助