如何使用webpack获取MDC的捆绑文件?

问题描述 投票:0回答:1

我正在使用Material Design Components for Web创建一个网站。我用SASS和JS完成了所有代码

我可以通过webpack服务器成功运行它,但现在我需要将文件上传到主机。我在哪里可以找到webpack所做的捆绑文件? (使用Dev服务器时,它们直接提供给浏览器)

I've tried all this

@import “@material/button/mdc-button”;
.foo-button {
@include mdc-button-ink-color(teal);
@include mdc-states(teal);
}
<button class="mdc-button foo-button">BUTTON</button>

请帮忙

npm webpack sass material-design mdc-components
1个回答
0
投票

你需要跑

npm run build

检查你的package.json,它必须包含相应的脚本

"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "webpack --config webpack.config.js"
}

您需要在目录的根目录中包含配置的webpack.config.js文件。

当你运行你的构建时,它将创建目录/ dist,你的包将在里面。

简单的webpack配置文件:

var path = require('path')
var webpack = require('webpack')
const HTMLWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'build.js'
  },
plugins: [
    new HTMLWebpackPlugin({
      template: "index.html"
    }),
    new CleanWebpackPlugin(['dist'])
  ]
}

在入境时要注意,你的名字和路径可能不同

必须通过npm install命令安装插件。

© www.soinside.com 2019 - 2024. All rights reserved.