Webpack compile less to css

This commit is contained in:
Tyler Long
2017-04-22 15:40:35 +08:00
parent acab3a5ee1
commit c52a8fc442
4 changed files with 644 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
import path from 'path'
import nodeExternals from 'webpack-node-externals'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
export const webConfig = () => {
return {
@@ -70,3 +71,40 @@ export const nodeConfig = () => {
}
}
}
export const lessConfig = () => {
return {
target: 'web',
entry: {
'mermaid': './src/less/default/mermaid.less',
'mermaid.dark': './src/less/dark/mermaid.less',
'mermaid.forest': './src/less/forest/mermaid.less',
'mermaid.neutral': './src/less/neutral/mermaid.less'
},
output: {
path: path.join(__dirname, './dist/'),
filename: '[name].css'
},
module: {
rules: [
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader'
},
{
loader: 'less-loader'
}
]
})
}
]
},
plugins: [
new ExtractTextPlugin('[name].css')
]
}
}