Created
March 17, 2018 01:24
-
-
Save matrixcloud/07eb57c8c9225d41e9f2045f4ab3fdae to your computer and use it in GitHub Desktop.
webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
module.exports = { | |
entry: './src/main.js', | |
output: { | |
filename: 'bundle.js', | |
path: path.resolve(__dirname, '../static') | |
}, | |
devtool: 'inline-source-map', | |
module: { | |
rules: [ | |
{ | |
enforce: "pre", | |
test: /\.js$/, | |
include: [ | |
path.resolve(__dirname, "src") | |
], | |
exclude: [ | |
path.resolve(__dirname, "node_modules"), | |
], | |
loader: "eslint-loader", | |
}, | |
{ | |
test: /\.js$/, | |
include: [ | |
path.resolve(__dirname, "src") | |
], | |
exclude: [ | |
path.resolve(__dirname, "node_modules") | |
], | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['env', 'react', 'stage-3'], | |
plugins: [ | |
'transform-decorators-legacy', | |
['import', { libraryName: 'antd', style: true }], | |
["transform-class-properties", { "spec": true }] | |
], | |
// directory for faster rebuilds. | |
cacheDirectory: true, | |
} | |
} | |
}, | |
{ | |
test: /\.less$/, | |
use: [ | |
{loader: "style-loader"}, // create style nodes from JS strings | |
{loader: "css-loader"}, // translates CSS into CommonJS | |
{loader: "less-loader"} // compiles Less to CSS | |
], | |
include: path.resolve(__dirname, "node_modules") | |
}, | |
{ | |
test: /\.less$/, | |
use: [ | |
{loader: "style-loader"}, // create style nodes from JS strings | |
{ | |
loader: "css-loader", | |
options: { | |
modules: true, | |
localIdentName: '[path][name]__[local]--[hash:base64:5]', | |
} | |
}, // translates CSS into CommonJS | |
{loader: "less-loader"} // compiles Less to CSS | |
], | |
exclude: path.resolve(__dirname, "node_modules") | |
}, | |
{ | |
test: /\.(png|jpe?g|gif)$/, | |
use: [ | |
{ | |
loader: 'url-loader', | |
options: { | |
limit: 8192 | |
} | |
}, | |
{ | |
loader: 'file-loader' | |
} | |
] | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment