Created
July 2, 2017 06:13
-
-
Save movii/b1c18bf5e6f07fd97e3967d83b9c048d to your computer and use it in GitHub Desktop.
笔记:Webpack 输出 UMD,extract-text-plugin 删除部分内容导致输出为空 - 9. 不会出现问题的 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
// 同时直接在 moda.js 直接引入 moda.scss | |
require('./moda.scss'); | |
function ModA () { | |
this.identifier = 'ModA'; | |
} | |
// ... |
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
var webpack = require('webpack'); | |
var path = require('path'); | |
var ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
module.exports = { | |
entry:'./src/moda.js', | |
output: { | |
filename: 'moda.js', | |
path: path.resolve(__dirname, 'dist'), | |
library: 'moda', | |
libraryTarget: 'umd', | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /.\css$/, | |
use: ['style-loader', 'css-loader'] | |
}, | |
{ | |
test: /\.scss$/, | |
use: ExtractTextPlugin.extract({ | |
use: ['css-loader', 'sass-loader'], | |
fallback: 'style-loader' | |
}) | |
}, | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/ | |
} | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin('moda.css') | |
], | |
devServer: { | |
compress: true, | |
port: 1333, | |
publicPath: '/dist/' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment