似乎我不知道如何将多个.scss文件提取到一个.css文件。构建我的/ dist文件夹后只构建.js文件。我跟着许多指南,但没有他们的工作。这是我的webpack.config.js
module.exports = {
entry: {
index: ["./src/app/index.ts"],
background: ["./src/background/background.ts"]
},
watch: true,
watchOptions: {
aggregateTimeout: 300,
ignored: /node_modules/
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "dist")
},
module: {
rules: [
{
test: /\.ts?$/,
loader: "awesome-typescript-loader",
exclude: [/\/node_modules\//]
}, {
test: /\.html$/,
loader: "html-loader"
}, {
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
//resolve-url-loader may be chained before sass-loader if necessary
use: ['css-loader', 'sass-loader']
})
}
]
},
plugins: [
new CopyWebpackPlugin([
{
from: "manifest.json",
to: "./"
}, {
from: "./node_modules/jquery/dist/jquery.js",
to: "./"
}
]),
new ExtractTextPlugin('style.css'),
new CleanWebpackPlugin("dist"),
],
resolve: {
extensions: [".ts", ".js"]
}
};
@edit我有最新的模块:
答案 0 :(得分:3)
你试试这种方式吗?
1)创建包含所需的所有scss导入的styles.scss:
2)创建文件:all-styles.js:
import style1 from "./styles/styles.scss";

3)在你的入口点添加all-styles.js:
entry: {
index: ["./src/app/index.ts"],
background: ["./src/background/background.ts"],
styles: ["./src/all-styles.js"]
},