0
我试图同时输出一个css作为我webpack.config文件中的JS包文件,但我现在面临两个问题:大厦CSS和使用的WebPack 1 Javascript文件
1)我的输出文件有一个。 js扩展名,但其中一个输出文件需要是一个css文件(scss.bundle.css)。我将如何完成这项工作?
2)我的装载机需要链接到正确的输出文件,我不认为这是正确的工作。
请让我知道你是否能够在这里帮助我。我认为webpack的知识非常有限。
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: "", // directory we currently in
devtool: debug ? "inline-sourcemap" : null,
entry: {
client: "./js/client.js",
scss: "./css/compactview.scss"
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js' // when out putting we create this kind of file
},
module: {
loaders: [
{
test: /\.js?$/, //anything thats a JS file gets run through babel-loader
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}
},
{
test: /\.scss$/, // any scss files
loaders: ['style', 'css', 'sass'],
include:
}
]
},
watch: true, //automatically watch files when running webpack
plugins: debug ? [] : [ //if in debug mode, no plugins - if in production ..
new webpack.optimize.HotModuleReplacementPlugin(),
new webpack.optimize.DedupePlugin(), //strip out duplicate code
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }), //gets rid of sourcemaps, comments, etc
],
};
'@ Quotidian'我不想从包中提取它,我想直接将.scss文件直接转换为.css文件,而无需先将其添加到某个webpack JavaScript包中,然后提取它从那里。 – Arjenovic
Webpack捆绑了一切以保留依赖关系,这就是为什么他们提供了提取插件。如果你不想要,那么webpack是错误的选择。 – Quotidian