Skip to content

Instantly share code, notes, and snippets.

@matrixcloud
Created March 17, 2018 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matrixcloud/07eb57c8c9225d41e9f2045f4ab3fdae to your computer and use it in GitHub Desktop.
Save matrixcloud/07eb57c8c9225d41e9f2045f4ab3fdae to your computer and use it in GitHub Desktop.
webpack
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