Browse Source

QFX-1451 feat: 开放less常量修改

master
fay 4 years ago
parent
commit
82468146eb
  1. 81
      webpack/webpack.common.js

81
webpack/webpack.common.js

@ -1,10 +1,23 @@
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const autoprefixer = require("autoprefixer");
const path = require("path");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const autoprefixer = require('autoprefixer');
const path = require('path');
const fs = require('fs');
const dirs = require("./dirs");
const dirs = require('./dirs');
const attachments = require("./attachments");
const attachments = require('./attachments');
let lessVariables = {};
if (process.env.LESS_CONFIG_PATH) {
const lessConfigPath = path.isAbsolute(process.env.LESS_CONFIG_PATH)
? process.env.LESS_CONFIG_PATH
: path.resolve(__dirname, '../', process.env.LESS_CONFIG_PATH);
lessVariables = fs.existsSync(lessConfigPath)
? require(lessConfigPath) || {}
: {};
}
module.exports = {
entry: {
@ -17,8 +30,8 @@ module.exports = {
underscore: '_',
},
resolve: {
mainFields: ["module", "main"],
extensions: [".js", ".ts"],
mainFields: ['module', 'main'],
extensions: ['.js', '.ts'],
},
module: {
rules: [
@ -26,17 +39,20 @@ module.exports = {
test: /\.(js|ts)$/,
include: [dirs.NODE_MODULES, dirs.PRIVATE, dirs.TYPESCRIPT],
exclude: /node_modules(\/|\\)core-js/,
use: [{
loader: "babel-loader",
options: {
configFile: dirs.IE8_BABEL_CONFIG,
use: [
{
loader: 'babel-loader',
options: {
configFile: dirs.IE8_BABEL_CONFIG,
},
},
}, {
loader: "source-map-loader",
options: {
enforce: "pre",
{
loader: 'source-map-loader',
options: {
enforce: 'pre',
},
},
}],
],
},
{
test: /\.js$/,
@ -51,9 +67,9 @@ module.exports = {
],
use: [
{
loader: "source-map-loader",
loader: 'source-map-loader',
options: {
enforce: "pre",
enforce: 'pre',
},
},
],
@ -63,44 +79,49 @@ module.exports = {
include: [path.resolve(__dirname, '../', attachments.lodash)],
use: [
{
loader: "script-loader",
loader: 'script-loader',
},
],
},
{
test: path.resolve(__dirname, '../', attachments.fix),
use: [{
loader: 'expose-loader',
options: 'Fix',
}],
use: [
{
loader: 'expose-loader',
options: 'Fix',
},
],
},
{
test: path.resolve(__dirname, '../', attachments.fixIE),
use: [{
loader: 'expose-loader',
options: 'Fix',
}],
use: [
{
loader: 'expose-loader',
options: 'Fix',
},
],
},
{
test: /\.(css|less)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
loader: 'css-loader',
options: {
url: false,
},
},
{
loader: "postcss-loader",
loader: 'postcss-loader',
options: {
plugins: [autoprefixer],
},
},
{
loader: "less-loader",
loader: 'less-loader',
options: {
relativeUrls: false,
modifyVars: lessVariables,
},
},
],

Loading…
Cancel
Save